: This article describes how to install nginx in a Linux operating system. if you are interested in the PHP Tutorial, refer to it. Download
cd /user/localwget http://nginx.org/download/nginx-1.8.0.tar.gz
Install dependencies
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
Extract
tar -zxvf nginx-1.8.0.tar.gz
Environment configuration
cd nginx-1.8.0./configure
Install
make && make install
Start
cd /usr/local/nginx./nginx
View
ps aux|grep nginx
Close
./nginx -s stop
Restart
./nginx -s reload
View Status:
./nginx -t
How to enable auto-start
cd /etc/init.dtouch nginx
After creating a new file, edit the file and paste the following content into it:
vi /etc/init.d/nginx
#!/bin/bash# nginx Startup script for the Nginx HTTP Server# it is v.0.0.2 version.# chkconfig: - 85 15# description: Nginx is a high-performance web and proxy server.# It has a lot of features, but it's not for everyone.# processname: nginx# pidfile: /var/run/nginx.pid# config: /usr/local/nginx/conf/nginx.confnginxd=/usr/local/nginx/sbin/nginxnginx_c/local/nginx/conf/nginx.confnginx_pid=/var/run/nginx.pidRETVAL=0prog="nginx"# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.[ ${NETWORKING} = "no" ] && exit 0[ -x $nginxd ] || exit 0# Start nginx daemons functions.start() {if [ -e $nginx_pid ];then echo "nginx already running...." exit 1fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL}# Stop nginx daemons functions.stop() { echo -n $"Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid}# reload nginx service functions.reload() { echo -n $"Reloading $prog: " #kill -HUP `cat ${nginx_pid}` killproc $nginxd -HUP RETVAL=$? echo}# See how we were called.case "$1" instart) start ;;stop) stop ;;reload) reload ;;restart) stop start ;;status) status $prog RETVAL=$? ;;*) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1esacexit $RETVAL
Grant execution permission
chmod +x /etc/init.d/nginx
Add Service
chkconfig --add nginx
Set startup
chkconfig --level 35 nginx on
Check whether the setting is successful
chkconfig --list | grep nginx
In this status, the surface boot is successful.
The above describes how to install nginx in the Linux operating system, including the chmod content, and hope to help anyone interested in the PHP Tutorial.