一键安装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
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
轉載于:https://blog.51cto.com/pc1990/1677579
總結
以上是生活随笔為你收集整理的一键安装lamp脚本--初级版的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 计算机485通讯原理,串口通信原理详解.
- 下一篇: 元启发式算法之一:蝙蝠算法BA