最近公司的項目很多,研發那裡需要的測試環境很多,而且基本都是lnmp的測試環境(也有apache與tomcat,但非常少),測試沒有問題之後還需要上線,所以最近我很忙,而且都是重複性的工作,本來我用虛擬機安裝一個lnmp的環境,但研發說必須用真實機器進行測試,所以為了偷懶,我只能用lnmp的自動安裝腳本了,剛開始使用還可以,但很多的腳本里都不能設置安裝路徑、軟體也是老版本的,所以我又根據我自己的實際需要編寫了一份模塊化的安裝lnmp腳本.
此腳本可以需要單獨的安裝mysql、nginx、php,還可以選擇自動的安裝lnmp,並且安裝的目錄都可以自己設定,很簡單與智能化,其中我編寫腳本的時候,參考了linuxeye的 LNMP源碼安裝腳本(http://linuxeye.blog.51cto.com/4371937/773362),也參考了張宴的博客(http://blog.s135.com/nginx_php_v6).感謝他們的分享精神.
本腳本我已經在rhel 5.4 32與64位系統都進行了測試,沒有發現問題,並且我在生產環境里也使用了這個腳本,也沒有發現問題.
一、準備工作
1、把install_lnmp.tar.gz上傳的到伺服器(我傳輸的目錄是tmp) 解壓查看install_lnmp.sh與soft是否解壓
- [root@localhost tmp]# tar zxf install_lnmp.tar.gz
運行install_lnmp.sh
- [root@localhost tmp]# ll
- total 64480
- -rwxr-xr-x 1 root root 13726 Mar 25 02:17 install_lnmp.sh
- -rw-r--r-- 1 root root 65911213 Mar 25 02:17 install_lnmp.tar.gz
- srwxr-xr-x 1 root root 0 Mar 23 14:19 mapping-root
- drwxr-xr-x 5 root root 4096 Mar 23 11:54 soft
- drwx------ 2 root root 4096 Mar 23 14:19 ssh-IMPTGZ3620
從輸出可以看出,可以使用install_yum、init、install_mysql等命令進行,下面介紹這些命令的含義 install_yum 如果本機的yum不能使用的時候,可以使用此命令 init 進行安裝所需的庫 install_mysql 進行mysql的安裝 install_nginx 進行nginx的安裝 install_php 進行php的安裝 install_lnmp 進行nginx、mysql、php與所需庫文件的安裝 install_check 進行檢查是否安裝nginx、mysql、php,並輸出安裝目錄 現在我們先進行檢查本機是否安裝了nginx、mysql、php,這裡使用install_check
- [root@localhost tmp]# sh install_lnmp.sh
- Usage:install_lnmp.sh {install_yum|init|install_mysql|install_nginx|install_php|install_lnmp|install_check}
從輸出可以看出,nginx、mysql、php都沒有安裝 在進行安裝的時候,可以使用nohup來進行後台的安裝,並且還有nohup.out目錄可以查看安裝的情況 二、腳本介紹 1、下載方法
- [root@localhost tmp]# sh install_lnmp.sh install_check
- Sun Mar 25 02:26:32 EDT 2012 Start install!
- ========================== Check install ================================
- Error: /usr/local/nginx not found!!!
- Error: /usr/local/php not found!!!
- Error: /usr/local/mysql not found!!!
- ========================== Check install ================================
- Sorry,Failed to install LNMP!
- Please check errors and logs.
- Sun Mar 25 02:26:32 EDT 2012 Finish install!
- Total runtime: 0 Seconds
- wget http://202.96.42.117/soft/ install_lnmp.tar.gz
- tar zxf install_lnmp.tar.gz
2、腳本中軟體的版本信息
- cmake-2.8.4.tar.gz
- mysql-5.5.10.tar.gz
- libiconv-1.13.1.tar.gz
- libmcrypt-2.5.8.tar.gz
- mhash-0.9.9.9.tar.gz
- mcrypt-2.6.8.tar.gz
- php-5.3.10.tar.gz
- memcache-2.2.5.tgz
- eaccelerator-0.9.6.1.tar.bz2
- PDO_MYSQL-1.0.2.tgz
- ImageMagick-6.6.7-10.tar.gz
- imagick-2.3.0.tgz
- pcre-8.12.tar.gz
- nginx-1.0.12.tar.gz
- ngx_cache_purge-1.3.tar.gz
3、腳本介紹
三、安裝 現在進行lnmp的安裝(使用nohup)
- #!/bin/bash
- #author dl528888
- #blog http://dl528888.blog.51cto.com
- LANG=C
- installhere="/data/software" #腳本與軟體包存放的地方
- nginx_dir="/usr/local/nginx" #nginx的安裝目錄
- php_dir="/usr/local/php" #php的安裝目錄
- mysql_dir="/usr/local/mysql" #mysql的安裝目錄
- mysql_datadir="/data/mysql/data" #mysql的數據存放目錄
- mysql_logdir="/data/mysql" #mysql的日誌目錄
- mysql_passwd="admin" #mysql的登陸密碼
- # Check if user is root #腳本需要在root用戶下運行,所以先進行用戶監測
- if [ $(id -u) != "0" ]; then
- echo "Error: You must be root to run this script, please use root to install soft"
- exit 1
- fi
- #Disable SeLinux #關閉selinux
- if [ -s /etc/selinux/config ]; then
- sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
- fi
- if [ ! -d "$installhere" ];then #如果腳本存放的目錄不存在,就自動的創建
- mkdir -p $installhere
- fi
- if [ ! -d "$installhere/soft" ];then #如果腳本不在那個存放的目錄里,則複製過去
- cp -a soft $installhere
- fi
- #set up runtime #進行運行時間的統計
- function start_time()
- {
- start_time="$(date %s)"
- echo "$(date) Start install!"
- echo "$start_time" > /tmp/Install_lnmp_runtime
- }
- function end_time()
- {
- end_time="$(date %s)"
- total_s=$(($end_time - $start_time))
- total_m=$(($total_s / 60))
- if [ $total_s -lt 60 ]; then
- time_en="${total_s} Seconds"
- else
- time_en="${total_m} Minutes"
- fi
- echo "$(date) Finish install!"
- echo "Install_lnmp.sh runtime: ${time_en} "> /tmp/Install_lnmp_runtime
- echo "Total runtime: ${time_en}"
- }
- #if yum fail,please use install_yum to solve. 如果yum不可用,可以使用此模塊來進行安裝yum
- function install_yum()
- {
- wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm
- wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
- rpm -Uvh rpmforge-release-0.5.1-1.el5.rf.i386.rpm
- rpm --import RPM-GPG-KEY.dag.txt
- yum -y install yum-fastestmirror yum-presto
- }
- #init set up Library 安裝lnmp需要的庫
- function init()
- {
- yum -y install yum-fastestmirror yum-presto
- yum -y install gcc gcc-c autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel nss_ldap openldap openldap-devel openldap-clients openldap-servers libxslt-devel libevent-devel ntp libtool-ltdl bison libtool vim-enhanced
- }
- #install mysql 安裝mysql的模塊
- function install_mysql()
- {
- cd $installhere/soft/mysql/
- useradd -M -s /sbin/nologin mysql
- mkdir -p $mysql_datadir;
- chown mysql.mysql -R $mysql_datadir
- tar xzf cmake-2.8.4.tar.gz
- cd cmake-2.8.4
- ./configure
- make && make install
- cd ..
- tar zxf mysql-5.5.10.tar.gz
- cd mysql-5.5.10
- cmake . -DCMAKE_INSTALL_PREFIX=$mysql_dir/ \
- -DMYSQL_DATADIR=$mysql_datadir \
- -DMYSQL_UNIX_ADDR=$mysql_logdir/mysqld.sock \
- -DWITH_INNOBASE_STORAGE_ENGINE=1 \
- -DENABLED_LOCAL_INFILE=1 \
- -DMYSQL_TCP_PORT=3306 \
- -DCMAKE_THREAD_PREFER_PTHREAD=1 \
- -DEXTRA_CHARSETS=all \
- -DDEFAULT_CHARSET=utf8 \
- -DDEFAULT_COLLATION=utf8_general_ci \
- -DMYSQL_UNIX_ADDR=$mysql_logdir/mysql.sock \
- -DWITH_DEBUG=0
- make && make install
- rm -rf /etc/my.cnf
- rm -rf /etc/init.d/mysqld
- mkdir $mysql_logdir/relaylog
- mkdir $mysql_logdir/binlog
- cp $installhere/soft/mysql/my.cnf /etc/my.cnf
- cp support-files/mysql.server /etc/init.d/mysqld
- chmod 755 /etc/init.d/mysqld
- chkconfig --add mysqld
- chkconfig mysqld on
- chown mysql.mysql -R $mysql_logdir
- chown mysql.mysql -R $mysql_datadir
- $mysql_dir/scripts/mysql_install_db --user=mysql --basedir=$mysql_dir --datadir=$mysql_datadir
- /sbin/service mysqld start
- echo 'export PATH=$PATH:'$mysql_dir'/bin' >> /etc/profile
- $mysql_dir/bin/mysql -e "grant all privileges on *.* to root@'%' identified by '$mysql_passwd' with grant option;"
- $mysql_dir/bin/mysql -e "flush privileges;"
- $mysql_dir/bin/mysql -e "delete from mysql.user where password='';"
- source /etc/profile
- /sbin/service mysqld restart
- echo "mysql install success!"
- }
- #install php 安裝php的模塊
- function install_php()
- {
- cd $installhere/soft/php
- tar xzf libiconv-1.13.1.tar.gz
- cd libiconv-1.13.1
- ./configure --prefix=/usr/local
- make && make install
- cd ../
- tar xzf libmcrypt-2.5.8.tar.gz
- cd libmcrypt-2.5.8
- ./configure
- make && make install
- /sbin/ldconfig
- cd libltdl/
- ./configure --enable-ltdl-install
- make && make install
- cd ../../
- tar xzf mhash-0.9.9.9.tar.gz
- cd mhash-0.9.9.9
- ./configure
- make && make install
- cd ../
- if [ -e "/lib64" ];then
- ln -s /usr/local/lib/libmcrypt.la /usr/lib64/libmcrypt.la
- ln -s /usr/local/lib/libmcrypt.so /usr/lib64/libmcrypt.so
- ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
- ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
- ln -s /usr/local/lib/libmhash.a /usr/lib64/libmhash.a
- ln -s /usr/local/lib/libmhash.la /usr/lib64/libmhash.la
- ln -s /usr/local/lib/libmhash.so /usr/lib64/libmhash.so
- ln -s /usr/local/lib/libmhash.so.2 /usr/lib64/libmhash.so.2
- ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
- ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
- ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /lib64/libmysqlclient.so.18
- else
- ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
- ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
- ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
- ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
- 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
- ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
- ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /lib/libmysqlclient.so.18
- fi
- tar xzf mcrypt-2.6.8.tar.gz
- cd mcrypt-2.6.8
- /sbin/ldconfig
- ./configure
- make && make install
- cd ../
- ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib
- if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then
- ln -s /usr/lib64/libpng.* /usr/lib/
- ln -s /usr/lib64/libjpeg.* /usr/lib/
- fi
- if [ ! `grep -l "/lib" '/etc/ld.so.conf'` ]; then
- echo "/lib" >> /etc/ld.so.conf
- fi
- if [ ! `grep -l '/usr/lib' '/etc/ld.so.conf'` ]; then
- echo "/usr/lib" >> /etc/ld.so.conf
- fi
- if [ -d "/usr/lib64" ] && [ ! `grep -l '/usr/lib64' '/etc/ld.so.conf'` ]; then
- echo "/usr/lib64" >> /etc/ld.so.conf
- fi
- if [ ! `grep -l '/usr/local/lib' '/etc/ld.so.conf'` ]; then
- echo "/usr/local/lib" >> /etc/ld.so.conf
- fi
- /sbin/ldconfig
- tar xzf php-5.3.10.tar.gz
- useradd -M -s /sbin/nologin www
- cd php-5.3.10
- ./configure --prefix=$php_dir --with-mysql=$mysql_dir --with-mysqli=$mysql_dir/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-ftp --enable-zip --enable-soap --disable-debug
- make ZEND_EXTRA_LIBS='-liconv'
- make install
- cp php.ini-production $php_dir/lib/php.ini
- cd ../
- tar xzf 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 xjf eaccelerator-0.9.6.1.tar.bz2
- cd eaccelerator-0.9.6.1
- /usr/local/php/bin/phpize
- ./configure --enable-eaccelerator=shared --with-php-config=$php_dir/bin/php-config
- make && make install
- cd ../
- tar xzf PDO_MYSQL-1.0.2.tgz
- cd PDO_MYSQL-1.0.2
- $php_dir/bin/phpize
- ./configure --with-php-config=$php_dir/bin/php-config --with-pdo-mysql=$mysql_dir
- make && make install
- cd ../
- tar xzf ImageMagick-6.6.7-10.tar.gz
- cd ImageMagick-6.6.7-10
- ./configure
- make && make install
- cd ../
- tar xzf imagick-2.3.0.tgz
- cd imagick-2.3.0
- /usr/local/php/bin/phpize
- ./configure --with-php-config=$php_dir/bin/php-config
- make && make install
- cd ../
- #Modiry php.ini
- mkdir /tmp/eaccelerator
- /bin/chown -R www.www /tmp/eaccelerator/
- sed -i '808a extension_dir = "'$php_dir'/lib/php/extensions/no-debug-non-zts-20090626/"' $php_dir/lib/php.ini
- sed -i '809a extension = "memcache.so"' $php_dir/lib/php.ini
- sed -i '810a extension = "pdo_mysql.so"' $php_dir/lib/php.ini
- sed -i '811a extension = "imagick.so"' $php_dir/lib/php.ini
- sed -i '134a output_buffering = On' $php_dir/lib/php.ini
- sed -i '847a cgi.fix_pathinfo=0' $php_dir/lib/php.ini
- sed -i 's@;date.timezone =@date.timezone = Asia/Shanghai@g' $php_dir/lib/php.ini
- echo '[eaccelerator]
- zend_extension="'$php_dir'/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
- eaccelerator.shm_size="64"
- eaccelerator.cache_dir="/tmp/eaccelerator"
- eaccelerator.enable="1"
- eaccelerator.optimizer="1"
- eaccelerator.check_mtime="1"
- eaccelerator.debug="0"
- eaccelerator.filter=""
- eaccelerator.shm_max="0"
- eaccelerator.shm_ttl="0"
- eaccelerator.shm_prune_period="0"
- eaccelerator.shm_only="0"
- eaccelerator.compress="0"
- eaccelerator.compress_level="9"
- eaccelerator.keys = "disk_only"
- eaccelerator.sessions = "disk_only"
- eaccelerator.content = "disk_only"' >> $php_dir/lib/php.ini
- echo ';;;;;;;;;;;;;;;;;;;;;
- ; FPM Configuration ;
- ;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;
- ; Global Options ;
- ;;;;;;;;;;;;;;;;;;
- [global]
- pid = run/php-fpm.pid
- error_log = log/php-fpm.log
- log_level = notice
- emergency_restart_threshold = 30
- emergency_restart_interval = 1m
- process_control_timeout = 5s
- daemonize = yes
- ;;;;;;;;;;;;;;;;;;;;
- ; Pool Definitions ;
- ;;;;;;;;;;;;;;;;;;;;
- [www]
- listen = 127.0.0.1:9000
- listen.backlog = -1
- listen.allowed_clients = 127.0.0.1
- listen.owner = www
- listen.group = www
- listen.mode = 0666
- user = www
- group = www
- pm = dynamic
- pm.max_children = 32
- pm.start_servers = 4
- pm.min_spare_servers = 4
- pm.max_spare_servers = 16
- pm.max_requests = 512
- request_terminate_timeout = 0
- request_slowlog_timeout = 0
- slowlog = log/$pool.log.slow
- rlimit_files = 51200
- rlimit_core = 0
- catch_workers_output = yes
- env[HOSTNAME] = $HOSTNAME
- env[PATH] = /usr/local/bin:/usr/bin:/bin
- env[TMP] = /tmp
- env[TMPDIR] = /tmp
- env[TEMP] = /tmp ' >> $php_dir/etc/php-fpm.conf
- echo "$php_dir/sbin/php-fpm" >> /etc/rc.local
- $php_dir/sbin/php-fpm
- echo '<?
- phpinfo();
- ?>' >$nginx_dir/html/phpinfo.php
- echo "php install success!"
- }
- #install nginx 安裝nginx的模塊
- function install_nginx()
- {
- cd $installhere/soft/nginx
- tar xzf pcre-8.12.tar.gz
- cd pcre-8.12
- ./configure
- make && make install
- cd ../
- tar xzf ngx_cache_purge-1.3.tar.gz
- tar xzf nginx-1.0.12.tar.gz
- cd nginx-1.0.12
- #Modify nginx Edition information
- sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION "1.0"@g' src/core/nginx.h
- sed -i 's@#define NGINX_VER.*NGINX_VERSION$@#define NGINX_VER "YWS/" NGINX_VERSION@g' src/core/nginx.h
- ./configure --prefix=$nginx_dir --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --add-module=../ngx_cache_purge-1.3
- make && make install
- cd $installhere/soft/nginx/
- cp nginx.sh /etc/init.d/nginx
- chmod 755 /etc/init.d/nginx
- chkconfig --add nginx
- chkconfig nginx on
- rm -rf $nginx_dir/conf/nginx.conf
- cp nginx.conf $nginx_dir/conf/nginx.conf
- echo "ulimit -SHn 65535" >>/etc/rc.local
- echo "$nginx_dir/sbin/nginx" >> /etc/rc.local
- echo '#ADD
- net.ipv4.tcp_max_syn_backlog = 65536
- net.core.netdev_max_backlog = 32768
- net.core.somaxconn = 32768
- net.core.wmem_default = 8388608
- net.core.rmem_default = 8388608
- net.core.rmem_max = 16777216
- net.core.wmem_max = 16777216
- net.ipv4.tcp_timestamps = 0
- net.ipv4.tcp_synack_retries = 2
- net.ipv4.tcp_syn_retries = 2
- net.ipv4.tcp_tw_recycle = 1
- #net.ipv4.tcp_tw_len = 1
- net.ipv4.tcp_tw_reuse = 1
- net.ipv4.tcp_mem = 94500000 915000000 927000000
- net.ipv4.tcp_max_orphans = 3276800
- #net.ipv4.tcp_fin_timeout = 30
- #net.ipv4.tcp_keepalive_time = 120
- net.ipv4.ip_local_port_range = 1024 65535' >>/etc/sysctl.conf
- /sbin/sysctl -p
- echo '#!/bin/bash
- # This script run at 00:00
- # The Nginx logs path
- logs_path="'$nginx_dir'/logs/"
- mkdir -p ${logs_path}$(date -d "yesterday" "%Y")/$(date -d "yesterday" "%m")/
- mv ${logs_path}access.log ${logs_path}$(date -d "yesterday" "%Y")/$(date -d "yesterday" "%m")/access_$(date -d "yesterday" "%Y%m%d").log
- kill -USR1 `cat '$nginx_dir'/nginx.pid` '>>$nginx_dir/sbin/cut_nginx_log.sh
- chmod 755 $nginx_dir/sbin/cut_nginx_log.sh
- echo "00 00 * * * /bin/bash $nginx_dir/sbin/cut_nginx_log.sh" >> /var/spool/cron/root
- $nginx_dir/sbin/nginx
- echo "nginx install success!"
- }
- #check install 檢測模塊
- function install_check()
- {
- echo "========================== Check install ================================"
- clear
- if [ -s $nginx_dir ]; then
- echo "$nginx_dir [found]"
- else
- echo "Error: $nginx_dir not found!!!"
- fi
- if [ -s $php_dir ]; then
- echo "$php_dir [found]"
- else
- echo "Error: $php_dir not found!!!"
- fi
- if [ -s $mysql_dir ]; then
- echo "$mysql_dir [found]"
- else
- echo "Error: $mysql_dir not found!!!"
- fi
- echo "========================== Check install ================================"
- if [ -s $nginx_dir ] && [ -s $php_dir ] && [ -s $mysql_dir ]; then
- echo "LNMP is completed! "
- echo "default mysql root password:$mysql_passwd"
- echo "The path of some dirs:"
- echo "mysql dir: $mysql_dir"
- echo "php dir: $php_dir"
- echo "php info: $nginx_dir/html/phpinfo.php"
- echo "nginx dir: $nginx_dir"
- echo "web dir : $nginx_dir/html"
- echo "=========================================================================="
- else
- echo "Sorry,Failed to install LNMP!"
- echo "Please check errors and logs."
- fi
- }
- case $1 in
- install_yum)
- install_yum
- ;;
- init)
- start_time
- init
- end_time
- ;;
- install_mysql)
- start_time
- install_mysql
- end_time
- ;;
- install_nginx)
- start_time
- install_nginx
- end_time
- ;;
- install_php)
- start_time
- install_php
- end_time
- ;;
- install_lnmp)
- start_time
- init
- install_mysql
- install_nginx
- install_php
- end_time
- ;;
- install_check)
- start_time
- install_check
- end_time
- ;;
- *)
- echo "Usage:`basename $0` {install_yum|init|install_mysql|install_nginx|install_php|install_lnmp|install_check}"
- ;;
- esac
可以看到安裝已經在後台進行,並且安裝情況都輸出到nohup.out里了 現在就是漫長的等待了......
- [root@localhost tmp]# nohup sh install_lnmp.sh install_lnmp &
- [1] 6861
- [root@localhost tmp]# nohup: appending output to `nohup.out'
- [root@localhost tmp]#
- [1] Done nohup sh install_lnmp.sh install_lnmp
結果可以看到腳本運行完成
現在可以看出腳本運行完成,我們查看一下日誌可以看到安裝運行了68分鐘(我在腳本里設置了運行時間,所以可以幫助我們觀察腳本運行的時間). 四、檢測 分別查看msyql、 nginx、php是否啟動
- [root@localhost tmp]# tail -f nohup.out
- net.ipv4.tcp_synack_retries = 2
- net.ipv4.tcp_syn_retries = 2
- net.ipv4.tcp_tw_recycle = 1
- net.ipv4.tcp_tw_reuse = 1
- net.ipv4.tcp_mem = 94500000 915000000 927000000
- net.ipv4.tcp_max_orphans = 3276800
- net.ipv4.ip_local_port_range = 1024 65535
- nginx install success!
- Sun Mar 25 03:47:26 EDT 2012 Finish install!
- Total runtime: 68 Minutes
從輸出可以看到,mysql、php、nginx都已經啟動了,我們在網頁里查看一下nginx與phpinfo.php 網頁能打開,證明nginx安裝成功
- [root@localhost tmp]# ps -ef|grep mysql
- root 9337 3848 0 03:49 pts/2 00:00:00 grep mysql
- root 25402 1 0 03:09 pts/2 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql/data --pid-file=/data/mysql/mysql.pid
- mysql 26280 25402 0 03:09 pts/2 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/mysql_error.log --open-files-limit=10240 --pid-file=/data/mysql/mysql.pid --socket=/tmp/mysql.sock --port=3306
- [root@localhost tmp]# ps -ef|grep nginx
- root 9321 1 0 03:47 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
- www 9322 9321 0 03:47 ? 00:00:00 nginx: worker process
- www 9325 9321 0 03:47 ? 00:00:00 nginx: worker process
- www 9326 9321 0 03:47 ? 00:00:00 nginx: worker process
- www 9327 9321 0 03:47 ? 00:00:00 nginx: worker process
- www 9328 9321 0 03:47 ? 00:00:00 nginx: worker process
- www 9329 9321 0 03:47 ? 00:00:00 nginx: worker process
- www 9330 9321 0 03:47 ? 00:00:00 nginx: worker process
- www 9331 9321 0 03:47 ? 00:00:00 nginx: worker process
- root 9339 3848 0 03:49 pts/2 00:00:00 grep nginx
- [root@localhost tmp]# ps -ef|grep php
- root 3431 1 0 03:45 ? 00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
- www 3432 3431 0 03:45 ? 00:00:00 php-fpm: pool www
- www 3433 3431 0 03:45 ? 00:00:00 php-fpm: pool www
- www 3434 3431 0 03:45 ? 00:00:00 php-fpm: pool www
- www 3435 3431 0 03:45 ? 00:00:00 php-fpm: pool www
- root 9341 3848 0 03:49 pts/2 00:00:00 grep php
可以看到php也已經安裝完成
下面我們在來通過install_check來檢查lnmp是否安裝完成
- [root@localhost tmp]# sh install_lnmp.sh install_check
- Sun Mar 25 04:04:24 EDT 2012 Start install!
- ========================== Check install ================================
- /usr/local/nginx [found]
- /usr/local/php [found]
- /usr/local/mysql [found]
- ========================== Check install ================================
- LNMP is completed!
- default mysql root password:admin
- The path of some dirs:
- mysql dir: /usr/local/mysql
- php dir: /usr/local/php
- php info: /usr/local/nginx/html/phpinfo.php
- nginx dir: /usr/local/nginx
- web dir : /usr/local/nginx/html
- ==========================================================================
- Sun Mar 25 04:04:24 EDT 2012 Finish install!
- Total runtime: 0 Seconds
可以看到,lnmp已經安裝完成.
希望大家能在使用本腳本過程中幫我進行糾錯與建議,謝謝!
BTW:感謝9樓小愚的建議,我經過測試發現是有他所說的問題出現,現在我已經把腳本修改了一下,修改內容為cp php.ini到$php_dir/lib目錄下.
希望能與小愚及各位同好一起交流、學習!
本文出自 「吟—技術交流」 博客,請務必保留此出處http://dl528888.blog.51cto.com/2382721/816542
[火星人 ] 模塊化的安裝lnmp腳本已經有632次圍觀