LNMP shell

来源:https://www.cnblogs.com/hackerer/archive/2018/12/13/10112763.html
-Advertisement-
Play Games

#!/bin/bash #set -x #date: 2018-12-13 #Description: 一鍵安裝LNMP環境 or LAMP 環境 #Version: 0.4 #Author: simon #定義命令搜索路徑 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/u... ...


#!/bin/bash  
#set -x  
#date: 2018-12-13
#Description: 一鍵安裝LNMP環境 or LAMP 環境 
#Version: 0.4  
#Author: simon  
#定義命令搜索路徑 
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin  
export PATH  
src_dir=/usr/src  
nginx_dir=/usr/local/nginx  
mysql_dir=/usr/local/mysql  
php_dir=/usr/local/php  
libmcrypt_dir=/usr/local/libmcypt  
apache_dir=/usr/local/apache 
#關閉SELiunx 
echo "Disabled SELinux"  
if [ -s /etc/selinux/config ]  
then  
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config  
fi 
 
/usr/sbin/setenforce 0  
# Check if user is root  
if [ "$UID" -ne 0 ]  
then  
    printf "Error: You must be root to run this script!\n"  
    exit 1  
fi  
 
#檢查需要的軟體包是否存在,如果沒有就下載。 
download_src(){  
cd $src_dir  
 
if [ -s libiconv-1.13.1.tar.gz ] 
then 
    echo "libiconv-1.13.1.tar.gz found" 
else 
    echo "libiconv-1.13.1.tar.gz not found. download new...." 
    wget http://mozbuildtools.googlecode.com/files/libiconv-1.13.1.tar.gz 
fi 
 
if [ -s mhash-0.9.9.9.tar.gz ] 
then 
    echo "mhash-0.9.9.9.tar.gz found" 
else 
    echo "mhash-0.9.9.9.tar.gz not found. download new....." 
    wget http://acelnmp.googlecode.com/files/mhash-0.9.9.9.tar.gz 
fi 
 
if [ -s mysql-5.5.25a.tar.gz ]  
then  
    echo "mysql-5.5.25a.tar.gz found"  
else  
    echo "mysql-5.5.25a.tar.gz not found. download new....."      
    wget http://mysql.ntu.edu.tw/Downloads/MySQL-5.5/mysql-5.5.25a.tar.gz   
fi 
  
if [ -s php-5.3.13.tar.gz ]  
then  
    echo "php-5.3.13.tar.gz found"  
else  
    echo "php-5.3.13.tar.gz not found. download new....."  
    wget http://us1.php.net/distributions/php-5.3.13.tar.gz  
fi 
  
if [ -s google-perftools-1.6.tar.gz ] 
then 
    echo "google-perftools-1.6.tar.gz found" 
else 
    echo "google-perftools-1.6.tar.gz not found. download new....." 
    wget http://gperftools.googlecode.com/files/google-perftools-1.6.tar.gz 
fi 
 
if [ -s cmake-2.8.4.tar.gz ]  
then  
    echo "cmake-2.8.4.tar.gz found......"  
else  
    echo "cmake-2.8.4.tar.gz not found. download new....."  
    wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz  
fi 
  
if [ -s libmcrypt-2.5.7.tar.gz ]  
then  
    echo "libmcrypt-2.5.7.tar.gz found"  
else  
    echo "libmcrypt-2.5.7.tar.gz not found. download new..."  
    wget http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/Production/libmcrypt-2.5.7.tar.gz  
fi 
  
if [ -s memcache-2.2.5.tgz ]  
then  
    echo "memcache-2.2.5.tgz found"  
else  
    echo "memcache-2.2.5.tgz not found. download new......"  
    wget http://vps.googlecode.com/files/memcache-2.2.5.tgz  
fi 
  
if [ -s eaccelerator-0.9.5.3.tar.bz2 ]  
then  
    echo "eaccelerator-0.9.5.3.tar.bz2 found"  
else  
    echo "eaccelerator-0.9.5.3.tar.bz2 not found. download new.."  
    wget http://autosetup1.googlecode.com/files/eaccelerator-0.9.5.3.tar.bz2  
fi 
  
if [ -s ImageMagick.tar.gz ]  
then  
    echo "ImageMagick.tar.gz found"  
else  
    echo "ImageMagick.tar.gz not found. download nrw."  
    wget http://www.imagemagick.org/download/ImageMagick.tar.gz  
fi 
  
if [ -s imagick-2.3.0.tgz ]  
then  
    echo "imagick-2.3.0.tgz found"  
else  
    echo  "imagick-2.3.0.tgz not found. download new"  
    wget http://lnmpp.googlecode.com/files/imagick-2.3.0.tgz  
fi  
}  
 
#初始化伺服器 
init_server(){  
for src in dialog ntp vim-enhanced vixie-cron gcc gcc-c++ gcc-g77 flex bison autoconf automake glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libtool* zlib-devel libxml2-devel libjpeg-devel libpng-devel libtiff-devel fontconfig-devel freetype-devel libXpm-devel gettext-devel curl curl-devel pam-devel e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel net-snmp net-snmp-devel nss_ldap openldap-clients openldap-servers libtidy libtidy-devel wget libc-client libc-client-devel pcre pcre-devel  
do  
    yum -y install $src  
done  
 
ln -s /usr/lib64/libc-client.so* /usr/lib/  
ln -s /usr/lib64/libldap* /usr/lib  
}  
 
 
#先檢測apache是否已經安裝,如果已經安裝就不在安裝,如果沒有安裝就安裝apache 
cd $src_dir 
inst_apache () { 
if [ -d $apache_dir ] 
then  
    echo "Apache is installed"  
    exit 1 
else  
    cd $src_dir 
    echo "Apache not install. install run..." 
    if [ -s httpd-2.2.24.tar.gz ] 
    then 
        echo "httpd-2.2.24.tar.gz found."  
    else 
            echo "httpd-2.2.24.tar.gz not found. download new...."  
            wget http://mirror.apache-kr.org/httpd/httpd-2.2.24.tar.gz 
        fi 
         
        if [ "$apache_mo" = "" ] 
        then 
        echo "你沒有輸入編譯參數,使用預設的參數進行編譯......." 
            tar zxvf httpd-2.2.24.tar.gz 
        cd $src_dir/httpd-2.2.24 
        ./configure --prefix=/usr/local/apache3 --enable-so --enable-rewrite --enable-mods-shared=most --with-mpm=worker 
        make && make install 
        cd ../ 
    else 
        tar zxvf httpd-2.2.24.tar.gz 
        cd $src_dir/httpd-2.2.24 
        $apache_mo 
        make && make install 
        fi 
 fi 
} 
  
#先檢測mysql是否已經安裝,如果已經安裝了就不再安裝,如果沒安裝就安裝mysql 
inst_mysql(){  
useradd -s /sbin/nologin -M mysql 
tar zxvf cmake-2.8.4.tar.gz  
cd $src_dir/cmake-2.8.4  
./configure && make && make install 
  
if [ -d $mysql_dir ]  
then  
    echo "MySQL is installed"  
else 
        if [ "$mysql_mo" = "" ] 
        then 
            echo "你沒有輸入mysql編譯參數,使用本腳本預設參數進行編譯......" 
            echo "MySQL not install. install run..."  
            cd $src_dir  
            tar zxvf mysql-5.5.25a.tar.gz  
            cd mysql-5.5.25a  
            cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_SSL=yes  -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=on  
            gmake && make install 
        else 
            echo "MySQL not install. install run..."  
            cd $src_dir 
            tar zxvf mysql-5.5.25a.tar.gz 
            cd mysql-5.5.25a 
            $mysql 
        fi 
fi  
 
if [ -f /ect/my.cnf ]  
then 
        cd $src_dir/mysql-5.5.25a 
        echo "MySQL config file my.cnf found. backup my.cnf to my.cnf.bak"  
        mv /etc/my.cnf /etc/my.cnf.bak  
        /bin/cp support-files/my-small.cnf /etc/my.cnf  
        /bin/cp support-files/mysql.server /etc/rc.d/init.d/mysqld  
        chmod 755 /etc/rc.d/init.d/mysqld 
        chown mysql:mysql /usr/local/mysql -R 
fi  
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql --defaults-file=/etc/my.cnf 
chown mysql:mysql /usr/local/mysql -R  
}  
  
inst_libmcypt(){  
if [ -d $libmcrypt_dir ]  
then  
        echo "libmcrypt is installed."  
else  
        cd $src_dir  
        tar zxvf libmcrypt-2.5.7.tar.gz  
        cd libmcrypt-2.5.7  
        ./configure --prefix=/usr/local/libmcypt && make && make install  
        /sbin/ldconfig 
        cd libltdl/ 
        ./configure --enable-ltdl-install 
        make 
        make install 
fi 
  
cd $src_dir 
tar zxf mhash-0.9.9.9.tar.gz 
cd mhash-0.9.9.9/ 
./configure 
make 
make install 
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a 
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la 
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so 
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2 
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1 
}  
#先檢測PHP是否已經編譯安裝,如果安裝了就不再進行安裝,如果沒安裝就安裝PHP 
inst_php_apache(){  
cd $src_dir 
tar zxf libiconv-1.13.1.tar.gz 
cd libiconv-1.13.1/ 
./configure --prefix=/usr/local 
make 
make install 
cd $src_dir  
if [ -d $php_dir ] 
then  
    echo "PHP is installed"  
else 
    if [ "$php_mo" = "" ] 
    then 
        echo "你沒有輸入編譯安裝參數,使用本腳本預設的參數進行編譯安裝.........." 
        echo "PHP not install. install run...."  
        cd $src_dir  
        tar zxvf php-5.3.13.tar.gz  
        cd php-5.3.13  
        ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/lib --with-mysql=/usr/local/mysql/bin/mysql_config --with-enable-sysvsem --with-apxs2=/usr/local/apache/bin/apxs --with-openssl --with-zlib --with-bz2 --with-curl --with-libxml-dir=/usr --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --enable-gd-native-ttf --enable-gd-jis-conv --without-iconv --with-ldap --with-mcrypt=/usr/local/libmcypt --with-zlib-dir --with-snmp --enable-zip --with-curlwrappers --with-imap --with-kerberos --with-imap-ssl --with-freetype-dir --with-mysql=/usr/local/mysql  
        make && make install  
        cp php.ini-development /usr/local/php/lib/php.ini  
        cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf 
    else 
        echo "使用你輸入的參數進行編譯安裝......." 
        echo "PHP not install. install run...."  
        cd $src_dir 
        tar zxvf php-5.3.13.tar.gz 
        cd php-5.3.13 
        $php_mo  
        make && make install  
        cp php.ini-development /usr/local/php/lib/php.ini 
        cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf 
    fi 
fi  
}  
inst_php(){  
cd $src_dir 
tar zxf libiconv-1.13.1.tar.gz 
cd libiconv-1.13.1/ 
./configure --prefix=/usr/local/libiconv 
make 
make install 
cd $src_dir  
if [ -d $php_dir)  
then  
    echo "PHP is installed"  
else  
        if [ "$php_mo" = "" ] 
        then 
        echo "你沒有輸入PHP安裝編譯參數,將使用本腳本預設參數進行編譯......" 
        sleep 5 
        echo "請選擇安裝方式,1,安裝和Nginx結合使用的PHP,2,安裝和apache結合使用的PHP....." 
        read -p "請輸入一個數字[1 | 2]: "  php_num 
            case $php_num in 
                1) 
                    echo "正在安裝和nginx結合使用的PHP.........."              
                    sleep 5 
                    echo "PHP not install. install run...."  
                    cd $src_dir  
                    tar zxvf php-5.3.13.tar.gz  
                    cd php-5.3.13  
                    ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/lib --with-mysql=/usr/local/mysql/bin/mysql_config --with-enable-sysvsem --enable-fpm --with-openssl --with-zlib --with-bz2 --with-curl --with-libxml-dir=/usr --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-iconv=/use/local/libiconv --with-ldap --with-mcrypt=/usr/local/libmcypt --with-zlib-dir --with-snmp --enable-zip --with-curlwrappers --with-imap --with-kerberos --with-imap-ssl --with-freetype-dir --with-mysql=/usr/local/mysql 
                    make && make install  
                    cp php.ini-development /usr/local/php/lib/php.ini  
                    cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf 
                ;; 
                2) 
                    echo "正在安裝和apache結合使用的PHP......." 
                    sleep 5 
                    ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/lib --with-mysql=/usr/local/mysql/bin/mysql_config --with-enable-sysvsem --with-apxs2=/usr/local/apache/bin/apxs --with-openssl --with-zlib --with-bz2 --with-curl --with-libxml-dir=/usr --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --enable-gd-native-ttf --enable-gd-jis-conv --without-iconv --with-ldap --with-mcrypt=/usr/local/libmcypt --with-zlib-dir --with-snmp --enable-zip --with-curlwrappers --with-imap --with-kerberos --with-imap-ssl --with-freetype-dir --with-mysql=/usr/local/mysql 
                    make && make install 
                    cp php.ini-development /usr/local/php/lib/php.ini 
                    cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf 
                ;; 
                *) 
                    echo "請輸入一個數字[1 | 2]: " 
            esac 
        else 
            echo "你輸入了PHP編譯安裝參數,使用你輸入的參數進行編譯......." 
            sleep 5 
            echo "PHP not install. install run...."  
            cd $src_dir 
            tar zxvf php-5.3.13.tar.gz 
            cd php-5.3.13 
            $php_mo 
            make && make install 
            cp php.ini-development /usr/local/php/lib/php.ini  
            cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf 
        fi 
fi  
} 
 
inst_php_nginx () { 
cd $src_dir 
tar zxf libiconv-1.13.1.tar.gz 
cd libiconv-1.13.1/ 
./configure --prefix=/usr/local 
make 
make install 
cd $src_dir  
if [ -d $php_dir)  
then  
    echo "PHP is installed"  
else  
        if [ "$php_mo" = "" ] 
        then 
            echo "你沒有輸入編譯安裝參數,使用本腳本預設的參數進行安裝" 
            echo "PHP not install. install run...."  
            cd $src_dir  
            tar zxvf php-5.3.13.tar.gz  
            cd php-5.3.13  
            ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/lib --with-mysql=/usr/local/mysql/bin/mysql_config --with-enable-sysvsem --enable-fpm --with-openssl --with-zlib --with-bz2 --with-curl --with-libxml-dir=/usr --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --enable-gd-native-ttf --enable-gd-jis-conv --without-iconv --with-ldap --with-mcrypt=/usr/local/libmcypt --with-zlib-dir --with-snmp --enable-zip --with-curlwrappers --with-imap --with-kerberos --with-imap-ssl --with-freetype-dir --with-mysql=/usr/local/mysql  
            make && make install  
            cp php.ini-development /usr/local/php/lib/php.ini  
            cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf 
        else 
            echo "你輸入了mysql編譯參數,使用你輸入的參數進行編譯........" 
            echo "PHP not install. install run...."  
            sleep 5 
            cd php-5.3.13 
            $php_mo 
            make && make install 
            cp php.ini-development /usr/local/php/lib/php.ini 
            cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf 
        fi 
             
fi  
} 
#安裝PHP擴展  
inst_php_ex(){  
cd $src_dir  
tar zxf memcache-2.2.5.tgz  
cd memcache-2.2.5/  
${php_dir}/bin/phpize  
./configure --with-php-config=${php_dir}/bin/php-config  
make  
make install  
cd ../  
  
tar jxf eaccelerator-0.9.5.3.tar.bz2  
cd eaccelerator-0.9.5.3  
${php_dir}/bin/phpize  
./configure --enable-eaccelerator=shared --with-eaccelerator-shared-memory --with-php-config=${php_dir}/bin/php-config  
make  
make install  
cd $src_dir  
  
tar zxf ImageMagick.tar.gz  
cd ImageMagick-6.8.1-9/  
./configure  
make  
make install  
cd ../ 
  
tar zxf imagick-2.3.0.tgz  
cd imagick-2.3.0/  
${php_dir}/bin/phpize 
./configure --with-php-config=${php_dir}/bin/php-config  
make  
make install  
cd ..  
echo "php extension installed successfully!"  
}  
#安裝nginx  
inst_nginx(){  
if [ -s nginx-1.3.10.tar.gz ]  
then  
    echo "nginx-1.3.10.tar.gz found."  
else  
    echo "nginx-1.3.10.tar.gz not found. download new...."  
    wget http://www.nginx.org/download/nginx-1.3.10.tar.gz  
fi 
  
cd $src_dir 
tar zxf google-perftools-1.6.tar.gz 
cd google-perftools* 
./configure 
make 
make install 
cd $src_dir 
 
if [ -d $nginx_dir ]  
then  
        echo "Nginx is installed"  
else  
    if [ "$nginx_mo" = "" ] 
    then 
        echo "你沒有輸入安裝參數,使用本腳本預設的參數進行編譯安裝" 
        cd $src_dir  
        tar zxvf nginx-1.3.10.tar.gz  
        cd nginx-1.3.10  
        ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_stub_status_module  
        make && make install 
    else 
        echo "你輸入了安裝參數,使用你輸入的參數進行安裝......" 
        cd $src_dir 
        tar zxvf nginx-1.3.10.tar.gz 
        cd nginx-1.3.10  
        $nginx_mo 
        make && make install 
    fi 
fi  
} 
  
#生成一個PHP啟動腳本,可以用service phpd start | restart | stop | show 進行啟動、重啟、關閉、查看運行狀態 
phpd(){ 
cat <<EOF >>phpd 
#!/bin/bash   
#Author: simon 
#Date: 2018-12-13
#   
#chkconfig: - 85 15   
#processname: php  
php=/usr/local/php/sbin/php-fpm   
conf=/usr/local/php/etc/php-fpm.conf   
case $1 in   
       start)   
              echo -n "Starting php"   
              $php   
              echo " done"   
       ;;   
      stop)   
              echo -n "Stopping php"   
              killall -9 php-fpm   
              echo " done"   
       ;;   
        restart)   
                $0 stop   
                $0 start   
       ;;   
       show)   
              ps -aux|grep php   
       ;;   
       *)   
              echo -n "Usage: $0 {start|restart|reload|stop|test|show}"   
       ;;   
esac 
EOF 
if [ -f /usr/src/phpd ] 
then 
    /bin/cp /usr/src/phpd /etc/rc.d/init.d/phpd 
    chmod +x /etc/rc.d/init.d/phpd 
fi 
} 
#生成nginx啟動腳本,可以用service nginxd start | restart | stop | reload | test | show 進行重啟、關閉、啟動>、測試配置文件、查看狀態和重新載入。 
nginxd(){ 
cat <<EOF >>/usr/src/nginxd 
#!/bin/bash   
#Author: simon
#Date: 2018-12-13
#   
#chkconfig: - 85 15   
#description: Nginx is a World Wide Web server.   
#processname: nginx   
nginx=/usr/local/nginx/sbin/nginx   
conf=/usr/local/nginx/conf/nginx.conf    
case $1 in   
       start)   
              echo -n "Starting Nginx"   
              $nginx -c $conf   
              echo " done"   
       ;;   
      stop)   
              echo -n "Stopping Nginx"   
              killall -9 nginx   
              echo " done"   
       ;;   
       test)   
              $nginx -t -c $conf   
       ;;   
        reload)   
              echo -n "Reloading Nginx"   
              ps auxww | grep nginx | grep master | awk '{print $2}' | xargs kill -HUP   
              echo " done"   
       ;;   
        restart)   
                $0 stop   
                $0 start   
       ;;   
       show)   
              ps -aux|grep nginx   
       ;;   
       *)   
              echo -n "Usage: $0 {start|restart|reload|stop|test|show}"   
       ;;   
esac 
EOF 
if [ -s /usr/src/nginxd ] 
then 
    /bin/cp /usr/src/nginxd /etc/rc.d/init.d/nginxd 
    chmod +x /etc/rc.d/init.d/nginxd 
fi 
} 
cat <<EOF 
############################################ 
  1 install Nginx 
  2 install PHP 
  3 install MySQL 
  4 install LNMP 
  5 install Apache 
  6 install LAMP 
############################################ 
############################################ 
Select your web server(1 | 2 | 3 | 4 | 5 | 6) 
EOF 
 
echo "Input a number: " 
read num 
case $num in   
   1)  
        read -p "請輸入nginx的編譯參數:" nginx_mo 
        echo "Nginx installing........... have a rest"  
        init_server  
        download_src  
        inst_nginx  
    ;;  
   2)  
        read -p "請輸入PHP的安裝參數" php_mo 
        echo "PHP installing....... have a rest"  
        download_src  
        init_server  
        inst_mysql  
        inst_libmcypt  
        inst_php  
        inst_php_ex 
    ;;  
    3)  
        read -p "請輸入mysql編譯安裝參數: " mysql_mo 
        echo "MySQL installing...... have a rest"  
        init_server   
        download_src  
        inst_mysql  
     ;;  
    4)  
            read -p "請輸入nginx的編譯參數:" nginx_mo 
            read -p "請輸入PHP的安裝參數" php_mo 
            read -p "請輸入mysql編譯安裝參數: " mysql_mo 
            echo "LNMP installing......  have a rest"  
            download_src  
            init_server  
            inst_mysql  
            inst_libmcypt  
            inst_php  
            inst_php_ex 
            inst_nginx   
    ;;  
    5) 
           read -p "請輸入apache編譯安裝參數: " apache_mo 
           echo "apache installing....... nave a rest."  
           download_src  
           init_server  
           inst_apache 
    ;; 
    6) 
          read -p "請輸入apache的安裝參數: " apache_mo 
          read -p "請輸入mysql的安裝參數: " mysql_mo 
          read -p "請輸入php的安裝參數: "  php_mo 
          echo "LAMP installing......... nave a rest." 
          download_src 
          init_server 
          inst_apache 
          inst_mysql 
          inst_libmcypt 
          inst_php_apache 
          inst_php_ex 
  ;;     
  *) 
          echo "Input error"          
          echo "Select your service(1 | 2 | 3 | 4| 5| 6)"          
;; 
esac 
  
#檢查安裝是否成功 
case $num in  
   4)  
    if [ -s /usr/local/nginx ] && [ -s /usr/local/php ] && [ -s /usr/local/mysql ]  
    then  
          echo "LNMP is install  completed"  
          echo "Nginx basedir: /usr/local/nginx"  
          echo "PHP basedir: /usr/local/php"  
          echo "MySQL basedir: /usr/local/mysql"  
          echo "MySQL datadir: /usr/local/mysql/data"  
    else  
         echo "LNMP is install fail"  
    fi  
   ;;  
   3)  
    if [ -s /usr/local/mysql ]  
    then  
        echo "Nginx is install completed"  
        echo "MySQL basedir: /usr/local/mysql"  
        echo "MySQL datadir: /usr/local/mysql/data"  
        phpd 
        nginxd 
    else  
        echo "Nginx is install fail"  
    fi  
    ;;  
   2)  
    if  [ -s /usr/local/php ]  
    then  
        echo "PHP is install completed"  
        echo "PHP basedir: /usr/local/php"  
        phpd 
    else  
        echo "PHP is install fail"  
    fi  
    ;;  
    1)  
    if [ -s /usr/local/nginx ]  
    then  
        echo "Nginx is install completed"  
        echo "Nginx basedir: /usr/local/nginx "  
        nginxd 
    else  
        echo "Nginx is install fail"  
    fi  
    ;;  
   5) 
      if [ -s /usr/local/apache ] 
      then 
          echo "Apache is installed completed." 
          echo "Apache basedir: /usr/local/nginx." 
      else 
          echo "Apache is install fail." 
      fi 
   ;; 
   6) 
       if [ -s /usr/local/apache ] && [ -s /usr/local/php ] && [ -s /usr/local/mysql ] 
       then 
            echo "LNMP is install  completed"  
            echo "Apache basedir: /usr/local/apache"  
            echo "PHP basedir: /usr/local/php"  
            echo "MySQL basedir: /usr/local/mysql"  
            echo "MySQL datadir: /usr/local/mysql/data"  
        else 
            echo "LNMP is install fail"  
        fi 
   ;; 
esac 

  


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 實際測試工作中偶爾會需要搭建Web伺服器環境,由於Mac OS X自帶了Apache和PHP環境,只需要簡單的啟動就可以。 開啟Apache 開啟Web伺服器的方法有兩種(預設啟動埠號是80): 打開:系統偏好配置 —— 共用 —— Web共用 終端可以通過Apache啟動命令打開:sudo ap ...
  • 本教程是在red hat linux 6.0環境下簡單測試!教程沒有圖片演示,需要具有一定Linux基礎知識,很多地方的配置需要根據自己的情況修改,照打不一定可以配置成功。(其他不足後續修改添加) yum安裝的配置 編輯文件 #vi /etc/yum.repos.d/packagekit-media ...
  • lsyncd 是一個支持實時、雙向、多機器的多模式文件同步工具。 ...
  • The VMware Authorization Service is not running。 原因 虛擬機服務沒有開啟 解決方法 ...
  • VM下載 VM是一款收費軟體,要找有密鑰的下載。 我的網盤 > 軟體 > 常用電腦工具 > VM VM安裝 參考鏈接中的安裝步驟 http://blog.java1234.com/blog/articles/290.html ...
  • 2)doPost和doGet的區別?(視頻下載) (全部書籍) 馬克-to-win:1)當用戶在瀏覽器地址欄輸入URL,2)點擊Web頁面 中的鏈接3)提交沒有指定METHOD的表單,4)或指定了METHOD=“GET”時,瀏覽器所發出的請求是GET請求。METHOD=“POST”的 表單所發出的請 ...
  • "https://stackoverflow.com/questions/4424193/what happens to mutex when the thread which acquired it exits?noredirect=1&lq=1" 解釋當一個lock了mutex的線程退出了,卻沒 ...
  • 設置(CentOS 6 vs CentOS 7)系統常用配置 ysvinit vs Upstart vs Systemd) 常見設置: 字元集CentOS 6方法:/etc/sysconfig/i18n中的LANG=CentOS 7方法1:localectl set-locale LANG=方法2 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...