(1)源码编译Apache WEB 服务
(2)源码编译MySQL DB 服务
(3)源码编译PHP WEB 服务
(4)LAMP源码整合+PHP页面创建
(5)对shell脚本优化,引入变量,条件判断
(二)案例脚本
#!/bin/bash #auto install LAMP #By author daqi #auto_lamp_config #Apache definne path variable H_FILES=httpd-2.2.34.tar.bz2 H_FILES_DIR=httpd-2.2.34 H_URL=http://mirrors.cnnic.cn/apache/httpd/ H_PREFIX=/usr/local/apache2/ #MySQL define path variable M_FILES=mysql-5.5.20.tar.gz M_FILES_DIR=mysql-5.5.20 M_URL=http://down1.chinaunix.net/distfiles/ M_PREFIX=/usr/local/mysql/ #PHP define path variable P_FILES=php-5.3.28.tar.bz2 P_FILES_DIR=php-5.3.28 P_URL=http://mirrors.sohu.com/php/ P_PREFIX=/usr/local/php5/ if [$# -eq 0];then echo -e "\033[36m---------------------------\033[0m" echo -e "\033[36mPlease Select Install Menu:\033[0m" echo "1)官方下载Httpd文件包." echo "2)官方下载MySQL文件包." echo "3)官方下载php文件包." echo "4)整合LAMP" echo -e "\033[36m---------------------------\033[0m" exit fi if [$1 -ne 1 -a $1 -ne 2 -a $1 -ne 3 -a $1 -ne 4];then echo -e "\033[36m---------------------------\033[0m" echo -e "\033[36mPlease Select Install Menu:\033[0m" echo "1)官方下载Httpd文件包." echo "2)官方下载MySQL文件包." echo "3)官方下载php文件包." echo "4)整合LAMP" echo -e "\033[36m---------------------------\033[0m" exit fi #Install httpd web server if [$1 -eq 1];then wget -c $H_URL/$H_FILES && tar -jxvf $H_FILES && cd $H_FILES_DIR &&./configure --prefix=$H_PREFIX make && make install exit fi #Install Mysql DB server if [$1 -eq 2];then useradd -s /sbin/nologin mysql wget -c $M_URL/$M_FILES && tar -xzvf $M_FILES && cd $M_FILES_DIR &&yum install cmake -y ;cmake . -DCMAKE_INSTALL_PREFIX=$M_PREFIX \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DMYSQL_DATADIR=/data/mysql \ -DSYSCONFDIR=/etc \ -DMYSQL_USER=mysql \ -DMYSQL_TCP_PORT=3306 \ -DWITH_XTRADB_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_EXTRA_CHARSETS=1 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=all \ -DWITH_BIG_TABLES=1 \ -DWITH_DEBUG=0 make && make install /bin/cp support-files/my-small.cnf /etc/my.cnf /bin/cp support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on make && make install exit fi #Install PHP server if [$1 -eq 3];then wget -c $P_URL/$P_FILES && tar -jxvf $P_FILES && cd $P_FILES_DIR &&./configure --prefix=$P_PREFIX --with-config-file-path=$P_PREFIX/etc --with-mysql=$M_PREFIX --with-apxs2=$H_PREFIX/bin/apxs make ZEND_EXTRA_LIBS='-liconv' && make install exit fi #Install lamp_config if [$1 -eq 4];then echo "AddType application/x-httpd-php .php" >>$H_PREFIX/conf/httpd.conf $H_PREFIX/bin/apachectl restart cat >$H_PREFIX/htdocs/index.php <<EOF <?php phpinfo(); ?> EOF fi |
原文地址:http://blog.51cto.com/linuxzdq/2044769