#!/bin/bash #auto install LANMP #by author ale #2019-4-30 20:39:04 #Httpd define path variable H_FILES=httpd-2.4.38.tar.gz H_FILES_DIR=httpd-2.4.38 H_URL=http://mirrors.cnnic.cn/apache/httpd/ H_PREFIX=/usr/local/apache #MysqL define path variable M_FILES=MysqL-5.5.20.tar.gz M_FILES_DIR=MysqL-5.5.20 M_PREFIX=/usr/local/MysqL M_YUM="cmake ncurses-devel ncurses pcre pcre-devel" #PHP define path variable P_FILES=PHP-5.6.10.tar.gz P_FILES_DIR=PHP-5.6.10 P_URL=http://ftp.ntu.edu.tw/PHP/distributions/ P_PREFIX=/usr/local/PHP P_YUM="gd curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel" #Nginx define path variable N_FILES=Nginx-1.12.2.tar.gz N_FILES_DIR=Nginx-1.12.2 N_URL=http://Nginx.org/download/ N_PREFIX=/usr/local/Nginx N_YUM="openssl openssl-devel" print_menu(){ echo -e "\033[32mPlease Select Install Menu follow:\033[0m" echo -e "\033[32m1)编译安装Apache服务\033[0m" echo -e "\033[32m2)编译安装Nginx服务\033[0m" echo -e "\033[32m3)编译安装MysqL服务\033[0m" echo -e "\033[32m4)编译安装PHP服务\033[0m" echo -e "\033[32m5)配置index.PHP并启动LAMP服务\033[0m" echo -e "\033[32m6)整合LNMP\033[0m" exit } apache_install(){ #Install httpd web server if [[ "$1" -eq "1" ]];then wget -c $H_URL/$H_FILES;tar -xzf $H_FILES;cd $H_FILES_DIR;./configure --prefix=$H_PREFIX --enable-so --enable-cgi --enable-rewrite --enable-module=most --enable-mpms-shared=all if [ $? -eq 0 ];then make &&make install cp $H_PREFIX/bin/apachectl /etc/init.d/httpd chmod o+x /etc/init.d/httpd fi fi } Nginx_install(){ #Install Nginx web server if [[ "$1" -eq "2" ]];then yum install -y $N_YUM wget -c $N_URL/$N_FILES;tar -xzf $N_FILES;cd $N_FILES_DIR;useradd www;./configure --prefix=$N_PREFIX --user=www --group=w ww --with-http_stub_status_module --with-http_ssl_module make && make install fi } MysqL_install(){ #Install MysqL server if [[ "$1" == "3" ]];then yum install -y $M_YUM tar -xf $M_FILES;cd $M_FILES_DIR;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 -j4 && make install -j4 cp support-files/my-small.cnf /etc/my.cnf cp support-files/MysqL.server /etc/init.d/MysqLd useradd MysqL;$M_PREFIX/scripts/MysqL_install_db --basedir=$M_PREFIX --datadir=/data/MysqL --user=MysqL chmod +x /etc/init.d/MysqLd chkconfig --add MysqLd fi } PHP_install(){ #Install PHP server if [[ "$1" -eq "4" ]];then yum -y install $P_YUM wget -c $P_URL/$P_FILES;tar -xzf $P_FILES;cd $P_FILES_DIR;./configure --prefix=$P_PREFIX --enable-fpm --with-pdo-MysqL --enable-debug --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-mbstring --with-curl --with-MysqL=$M_PREFIX --with-config-file-path=$P_PREFIX/etc --with-apxs2=$H_PREFIX/bin/apxs if [ $? -eq 0 ];then make -j4 && make install -j4 cp PHP.ini-development $P_PREFIX/etc/PHP.ini cp $P_PREFIX/etc/PHP-fpm.conf.default $P_PREFIX/etc/PHP-fpm.conf $M_PREFIX/sbin/PHP-fpm cp sapi/fpm/init.d.PHP-fpm /etc/init.d/PHP-fpm chmod o+x /etc/init.d/PHP-fpm echo -e "\033[32mThe PHP Server Install Success\033[0m" else echo -e "\033[32mThe PHP Server Install Failed,Please check..\033[0m" fi fi } lamp_config(){ if [[ "$1" = "5" ]];then sed -i '/DirectoryIndex/s/index.html/index.PHP index.html/g' $H_PREFIX/conf/httpd.conf $H_PREFIX/bin/apachectl restart echo "AddType application/x-httpd-PHP .PHP" >>$H_PREFIX/conf/httpd.conf IP=`ifconfig ens33|grep "broadcast"|awk '{print $2}'|cut -d: -f2` echo "You can access http://$IP/" cat >$H_PREFIX/htdocs/index.PHP <<EOF <?PHP PHPinfo(); ?> EOF fi } lnmp_config(){ if [[ "$1" = "6" ]];then \cp Nginx.conf.swp $N_PREFIX/conf/Nginx.conf cat >$N_PREFIX/html/index.PHP <<EOF <?PHP PHPinfo(); ?> EOF $N_PREFIX/sbin/Nginx /etc/init.d/PHP-fpm restart /etc/init.d/MysqLd restart systemctl stop firewalld setenforce 0 fi } case $1 in 1) apache_install $1 ;; 2) Nginx_install $1 ;; 3) MysqL_install $1 ;; 4) PHP_install $1 ;; 5) lamp_config $1 ;; 6) lnmp_config $1 ;; *) print_menu ;; esac
Nginx.conf.swp 内容以下
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } location ~ \.PHP$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.PHP; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。