本文共 3767 字,大约阅读时间需要 12 分钟。
#!/bin/bash#write by zhang_pc#at 2015.08.07#apache2.4 php.5.4 mysql5.5#脚本说明,如果脚本所在目录有源码包就用本地的,否则就从互联网下载APR_FILES=apr-1.5.2.tar.gzAPR_DIR=apr-1.5.2ARP_PRE=/usr/local/aprAPR_URL=http://mirror.bit.edu.cn/apache/apr/apr-1.5.2.tar.gzAPR_U_FILES=apr-util-1.5.4.tar.gzAPR_U_DIR=apr-util-1.5.4APR_U_PRE=/usr/local/apr-utilAPR_U_URL=http://mirror.bit.edu.cn/apache/apr/apr-util-1.5.4.tar.gzA_FILES=httpd-2.4.16.tar.gzA_DIR=httpd-2.4.16A_PRE=/usr/local/apacheA_URL=http://mirrors.sohu.com/apache/httpd-2.4.16.tar.gzM_FILES=mysql-5.5.44.tar.gzM_DIR=mysql-5.5.44M_PRE=/usr/local/mysqlM_URL=http://download.softagency.net/MySQL/Downloads/MySQL-5.5/mysql-5.5.44.tar.gzP_FILES=php-5.4.22.tar.gzP_DIR=php-5.4.22P_PRE=/usr/local/phpP_URL=http://mirrors.sohu.com/php/php-5.4.22.tar.gz function apr_install() {yum install -y gcctar -zxvf $APR_FILES;cd $APR_DIR;./configure --prefix=$APR_PRE && make && make installif [ $? -eq 0 ];then echo "the apr install is successful"else echo "the apr install is failed"fi}function apr_util_install() { tar -zxvf $APR_U_FILES;cd $APR_U_DIR;./configure --prefix=$APR_U_PRE --with-apr=$APR_PRE && make && make installif [ $? -eq 0 ];then echo "the apr_util install is successful"else echo "the apr_util install is failed"fi}function apache_install() {yum install pcre-devel openssl-devel -ytar -zxvf $A_FILES;cd $A_DIR./configure --prefix=$A_PRE --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-arp=$APR_PRE --with-apr-util=$APR_U_PRE --enable-modules=most --enable-mpms-shared=all --with-mpm=preforkmake -j2 && make install -j2 if [ $? -eq 0 ];then echo "the apache install is successful" elseecho "the apache install is failed" exit fi}function mysql_install() {yum install gcc-c++ cmake ncurses-devel bison perl -yuseradd -s /sbin/nologin mysql mkdir -p /data/mysqlchown -R mysql.mysql /data/mysqltar -zxvf $M_FILES;cd $M_DIRcmake -DCMAKE_INSTALL_PREFIX=$M_PRE -DMYSQL_DATADIR=/data/mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=0 -DMYSQL_USER=mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock make -j2 && make install if [ $? -eq 0 ];then echo "the mysql is successful" else echo "the mysql is failed" exit fi}function php_install() {yum install libxml2-devel libmcrypt-devel bzip2-devel libxml2-devel openssl-devel bzip2 bzip2-devel -ytar -zxvf $P_FILES;cd $P_DIR./configure --prefix=$P_PRE --with-config-file-path=$P_PRE/etc --with-apxs2=$A_PRE/bin/apxs --with-mysql=$M_PREmake -j2 && make install if [ $? -eq 0 ];then echo "the php is successful" else echo "the php is failed" exit fi}function lamp_zh() {sed -i "s/#ServerName www.example.com:80/ServerName www.example.com:80/g" /usr/local/apache/conf/httpd.confsed -i "s/DirectoryIndex index.html/DirectoryIndex index.php index.html/g" /usr/local/apache/conf/httpd.confsed -i '310a AddType application/x-httpd-php .php' /usr/local/apache/conf/httpd.conf/usr/local/apache/bin/apachectl start/bin/cp ./$M_DIR/support-files/my-medium.cnf /etc/my.cnf/bin/cp ./$M_DIR/support-files/mysql.server /etc/init.d/mysqldchmod 755 /etc/init.d/mysqldsed -i '38a datadir=/data/mysql' /etc/my.cnfsed -i '38a basedir=/usr/local/mysql' /etc/my.cnf/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql/etc/init.d/mysqld startchkconfig --add mysqldecho "PATH=$PATH:/usr/local/mysql/bin">>/etc/profilesource /etc/profile}cat <
转载于:https://blog.51cto.com/pc1990/1682753