CentOS Configuration nginx1.8.0
-y install gcc gcc-c++-y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
- Download Nginx, unzip, compile and install
wget http://nginx.org/download/nginx-1.8.0.tar.gztar zxvf nginx-1.8.0.tar.gzcd nginx-1.8.0./configuremake && make install
/usr/local/nginx/sbin/nginx
At this point, the native IP can be accessed through a browser, and the following fields appear:
First, create the Nginx file under the/etc/init.d/directory of the Linux system, using the following command:
Vi/etc/init.d/nginx
Add the following command to the script:
*************************************************************************************************************** ******************#!/bin/bash# nginx Startup script for the Nginx HTTP Server# It is v.0.0.2 version.# Chkconfig:- about# 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 are up.[${networking}="No"] &&Exit0[-X$nginxd] ||Exit0# Start Nginx daemons functions.Start() {if[- e$nginx _pid]; ThenEcho"Nginx already running ..."Exit1fiEcho-N $"Starting $prog:"Daemon$nginxd-C${nginx_config}Retval=$?Echo[$RETVAL=0] && Touch/var/lock/subsys/nginxreturn$RETVAL}# Stop Nginx daemons functions.Stop() {Echo-N $"Stopping $prog:"Killproc$nginxdRetval=$?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"$"inchStart) Start; stop) stop;; reload) reload;; restart) stop start;; Status) status$progRetval=$? ;; *)Echo$"Usage: $prog {start|stop|restart|reload|status|help}"Exit1EsacExit$RETVAL*************************************************************************************************************** ******************
Where the following code is modified according to the location of your system
nginxd=/usr/local/nginx/sbin/nginxnginx_c>/usr/local/nginx/conf/nginx.confnginx_pid=/var/run/nginx.pid
Next, set access permissions for the file:
chmod a+x/etc/init.d/nginx (a+x parameter means ==> all user can execute)
Finally, add the Ngix to the rc.local file so that the Nginx will start by default.
Vi/etc/rc.local
Add to
/etc/init.d/nginx start
Save and exit
The next reboot will take effect, realizing nginx self-booting.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the CentOS configuration nginx180, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.