码迷,mamicode.com
首页 > 其他好文 > 详细

一键安装lamp脚本--初级版

时间:2015-07-23 15:50:27      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:脚本 lamp

#!/bin/bash

#write by zhang_pc

#at 2015.07.21

#apache2.2.27 mysql5.1 php5.4

#安装说明,由于网速原因,就不下载了,执行脚本前要把源码上传到脚本相同的目录下

echo -e "\033[32m this is a lamp 一键安装script\033[0m"

echo -e "\033[32m 第一步安装apache \033[0m"

echo -e "\033[32m 第二步安装mysql \033[0m"

echo -e "\033[32m 第三步安装php \033[0m"

echo -e "\033[32m lamp整合并启动服务 \033[0m"


file_a=httpd-2.2.27.tar.gz

dir_a=httpd-2.2.27

file_m=mysql-5.1.63.tar.gz

dir_m=mysql-5.1.63

file_p=php-5.4.13.tar.bz2

dir_p=php-5.4.13


-------------------------------------------------------------------------------


#安装apache

yum install -y gcc

tar -zxvf $file_a;cd $dir_a

./configure --prefix=/usr/local/apache --enable-so --enable-rewrite

make -j2 && make install -j2

if [ $? -eq 0 ];then

 echo -e "\033[32m the apache is successful\033[0m"

else

 echo -e "\033[32m the apache is failed\033[0m"

 exit

fi


----------------------------------------------------------------------------------


#安装mysql

cd ..

yum install -y ncurses-devel gcc-c++

tar -zxvf $file_m;cd $dir_m

./configure  --prefix=/usr/local/mysql --enable-assembler

make -j2 && make install -j2

if [ $? -eq 0 ];then

 echo -e "\033[32m the mysql is successful\033[0m"

else

 echo -e "\033[32m the mysql is failed\033[0m"

 exit

fi


-------------------------------------------------------------------------------------


#安装php

cd ..

yum install -y libxml2-devel

tar -jxvf $file_p;cd $dir_p

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc   --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/

make -j2 && make install -j2

if [ $? -eq 0 ];then

 echo -e "\033[32m the php is successful\033[0m"

else

 echo -e "\033[32m the php is failed\033[0m"

fi


-------------------------------------------------------------------------------------


#整合lamp,并启动服务

sed -i "s/#ServerName www.example.com:80/ServerName www.example.com:80/g" /usr/local/apache/conf/httpd.conf

sed -i "s/DirectoryIndex index.html/DirectoryIndex index.html index.php/g" /usr/local/apache/conf/httpd.conf

sed -i ‘310a AddType application/x-httpd-php .php‘  /usr/local/apache/conf/httpd.conf

/usr/local/apache/bin/apachectl start


cd ..

/bin/cp  ./$dir_m/support-files/my-medium.cnf  /etc/my.cnf

/bin/cp  ./$dir_m/support-files/mysql.server   /etc/init.d/mysqld

chmod 755  /etc/init.d/mysqld

mkdir -p /data/mysql

useradd -s /sbin/nologing mysql

chown  -R  mysql.mysql  /data/mysql

sed -i ‘38a datadir=/data/mysql‘ /etc/my.cnf

sed -i ‘38a basedir=/usr/local/mysql‘ /etc/my.cnf

/usr/local/mysql/bin/mysql_install_db  --user=mysql

/etc/init.d/mysqld start

chkconfig --add mysqld && chkconfig --level mysqld 35 on


本文出自 “pc的个人博客” 博客,请务必保留此出处http://pc1990.blog.51cto.com/10541224/1677579

一键安装lamp脚本--初级版

标签:脚本 lamp

原文地址:http://pc1990.blog.51cto.com/10541224/1677579

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!