CentOS 6.8编译安装LNMP环境(3)

./configure时:--with-openssl=/usr/local/src/openssl-1.0.1j --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.36指向的是源码包解压的路径,而不是安装的路径,否则会报错
[root@Zabbix_Server nginx-1.6.2]# vim /etc/rc.d/init.d/nginx    #添加nginx启动文件 
#!/bin/sh
 
#
 
# nginx - this script starts and stops the nginx daemon
 
#
 
# chkconfig: - 85 15
 
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
 
# proxy and IMAP/POP3 proxy server
 
# processname: nginx
 
# config: /etc/nginx/nginx.conf
 
# config: /app/nginx/conf/nginx.conf
 
# pidfile: /app/nginx/logs/nginx.pid
 
# Source function library.
 
. /etc/rc.d/init.d/functions
 
# Source networking configuration.
 
. /etc/sysconfig/network
 
# Check that networking is up.
 
[ "$NETWORKING" = "no" ] && exit 0
 
nginx="/app/nginx/sbin/nginx"
 
prog=$(basename $nginx)
 
NGINX_CONF_FILE="/app/nginx/conf/nginx.conf"
 
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
 
lockfile=/var/lock/subsys/nginx
 
make_dirs() {
 
# make required directories
 
user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
 
if [ -z "`grep $user /etc/passwd`" ]; then
 
useradd -M -s /bin/nologin $user
 
fi
 
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
 
for opt in $options; do
 
if [ `echo $opt | grep '.*-temp-path'` ]; then
 
value=`echo $opt | cut -d "=" -f 2`
 
if [ ! -d "$value" ]; then
 
# echo "creating" $value
 
mkdir -p $value && chown -R $user $value
 
fi
 
fi
 
done
 
}
 
start() {
 
[ -x $nginx ] || exit 5
 
[ -f $NGINX_CONF_FILE ] || exit 6
 
make_dirs
 
echo -n $"Starting $prog: "
 
daemon $nginx -c $NGINX_CONF_FILE
 
retval=$?
 
echo
 
[ $retval -eq 0 ] && touch $lockfile
 
return $retval
 
}
 
stop() {
 
echo -n $"Stopping $prog: "
 
killproc $prog -QUIT
 
retval=$?
 
echo
 
[ $retval -eq 0 ] && rm -f $lockfile
 
return $retval
 
}
 
restart() {
 
#configtest || return $?
 
stop
 
sleep 1
 
start
 
}
 
reload() {
 
#configtest || return $?
 
echo -n $"Reloading $prog: "
 
killproc $nginx -HUP
 
RETVAL=$?
 
echo
 
}
 
force_reload() {
 
restart
 
}
 
configtest() {
 
$nginx -t -c $NGINX_CONF_FILE
 
}
 
rh_status() {
 
status $prog
 
}
 
rh_status_q() {
 
rh_status >/dev/null 2>&1
 
}
 
case "$1" in
 
start)
 
rh_status_q && exit 0
 
$1
 
;;
 
stop)
 
rh_status_q || exit 0
 
$1
 
;;
 
restart|configtest)
 
$1
 
;;
 
reload)
 
rh_status_q || exit 7
 
$1
 
;;
 
force-reload)
 
force_reload
 
;;
 
status)
 
rh_status
 
;;
 
condrestart|try-restart)
 
rh_status_q || exit 0
 
;;
 
*)
 
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
 
exit 2
 
esac
[root@Zabbix_Server nginx-1.6.2]# chmod 775 /etc/rc.d/init.d/nginx 
[root@Zabbix_Server nginx-1.6.2]# chkconfig nginx on
[root@Zabbix_Server nginx-1.6.2]# /etc/rc.d/init.d/nginx restart
[root@Zabbix_Server nginx-1.6.2]# cp /etc/sysconfig/iptables{,20160902bak}
[root@Zabbix_Server nginx-1.6.2]# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
[root@Zabbix_Server nginx-1.6.2]# /etc/rc.d/init.d/iptables restart

在浏览器中打开服务器IP地址,会看到下面的界面,说明Nginx安装成功。

CentOS 6.8编译安装LNMP环境

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5a1fda6d652fbdd09da3d10ae83a6c31.html