First, software configuration information
CentOS 6.5
Second, the necessary software preparation
Check the installation Pcre,openssl,gzip command as follows:
Yum install-y zlib zlib-devel pcre pcre-devel OpenSSL openssl-devel
Third, create Nginx users and Groups
[[email protected] src]# groupadd nginx [[email protected] src]# useradd-r-G nginx-s/sbin/nologin-m Nginx
Iv. Download and Unzip
Nginx can be downloaded from official website: http://nginx.org/
can also be downloaded directly from the command, my current directory is/usr/local/src:
[Email protected] src]# wget http://nginx.org/download/nginx-1.10.1.tar.gz
Extract:
[Email protected] src]# tar zxvf nginx-1.10.1.tar.gz [[email protected] src]# CD nginx-1.10.1
Five, start the installation
[[email protected] src]# cd nginx-1.6.3 [[email protected] nginx-1.6.3]# ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx -- Conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path =/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock -- Http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_ temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/ uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx -- With-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_ Module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_ Gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_ Module --with-http_auth_request_module --with-file-aio --with-http_spdy_module --with-ipv6 --with-pcre ./configure \ --prefix=/usr/local/nginx \ - -sbin-path=/usr/sbin/nginx \ --conf-path=/usr/local/nginx/conf/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/ nginx/access.log \ --pid-path=/var/run/nginx.pid \ -- Lock-path=/var/run/nginx.lock \ --http-client-body-temp-path=/var/cache/nginx/client_ temp \ --http-proxy-temp-path=/var/cache/nginx/proxy_temp \ -- Http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ --http-uwsgi-temp-path=/var/cache /nginx/uwsgi_temp&nbsP; \ --http-scgi-temp-path=/var/cache/nginx/scgi_temp \ --user=nginx \ --group=nginx \ --with-http_ssl_module \ --with-http_realip_module \ --with-http_addition_module \ -- With-http_sub_module \ --with-http_dav_module \ --with-http_flv_ module \ --with-http_mp4_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_random_index_module \ --with-http_secure_link_module \ --with-http_stub_status_module \ --with-http_auth_request_module \ --with-file-aio \ --with-http_ Spdy_module \ --with-ipv6 \ --with-pcre [[email protected] ngiNx-1.6.3]# make [[email protected] nginx-1.6.3]# make install
Six, start stop
Start command:
[Email protected] nginx-1.6.3]#/usr/sbin/nginx
Test to read Web information directly with the Curl command:
[Email protected] sbin]# Curl-s http://localhost | grep nginx.com
Close command:
[[email protected] nginx-1.6.3]#/usr/sbin/nginx-s stop Reload, when you modify the configuration, with this command does not need to restart the effective: [[email protected] nginx-1.6.3]# /usr/sbin/nginx-s Reload
Seven, the provision of nginx system services
Add the following file:
vi /etc/init.d/nginx#!/bin/sh # # nginx startup script for nginx # # chkconfig: - 85 15 # processname: nginx # config: /etc/nginx/nginx.conf # config: /etc/sysconfig/nginx # pidfile: /var/run/nginx.pid # description: nginx is an HTTP and reverse proxy server # ### begin init info # provides: nginx # Required-Start: $local _fs $remote _fs $network # required-stop: $ local_fs $remote _fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start and Stop nginx ###&nbsP end init info # source function library. . / etc/rc.d/init.d/functions if [ -l $0 ]; then initscript= '/bin/readlink -f $0 ' else initscript=$0 fi sysconfig= '/bin/basename $initscript ' if [ -f /etc/sysconfig/$sysconfig ]; then . /etc/sysconfig/$sysconfig fi nginx=${nginx-/usr/sbin/ nginx} prog= '/bin/basename $nginx ' conffile=${CONFFILE-/etc/nginx/nginx.conf} lockfile=${LOCKFILE-/var/lock/subsys/nginx} pidfile=${PIDFILE-/var/run/nginx.pid} sleepmsec=${sleepmsec-200000} upgradewaitloops=${upgradewaitloops-5} retval=0 start () { echo -n $ "starting $prog: " daemon --pidfile=${pidfile} ${nginx} -c ${conffile} retval=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } stop () { echo -n $ "stopping $prog: " killproc -p ${pidfile} ${prog} RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} } reload () { echo -n $ "reloading $prog: " killproc -p ${pidfile} ${prog } -hup retval=$? echo } upgrade () { oldbinpidfile=${pidfile}.oldbin configtest -q | | return echo -n $ "starting new master $prog: " killproc -p ${pidfile} ${prog} -USR2 echo for i in '/ usr/bin/seq $UPGRADEWAITLOOPS '; do /bin/ usleep $SLEEPMSEC if [ -f ${ Oldbinpidfile} -a -f ${pidfile} ]; then echo -n $ "Graceful shutdown of old $prog: " killproc -p ${oldbinpidfile} ${prog} -QUIT RETVAL=$? echo return fi done echo $ "Upgrade failed!" retval=1 } configtest () { if [ "$#" -ne 0 ] ; then case " $ " in -q) FLAG=$1 ;; *) ;; esac shift fi ${nginx} -t -c ${conffile} $FLAG RETVAL=$? return $RETVAL } rh_status () { status -p ${pidfile} ${nginx} } # see how we were called. case "$" in start) rh_status >/dev/null 2>&1 && exit 0 start ;; stop) stop ;; status) rh_ status retval=$? ;; restart) configtest -q | | exit $retval stop start ;; upgrade) rh_ status >/dev/null 2>&1 | | exit 0 upgrade ;; condrestart|try-restart) if rh_status >/dev/null 2>&1; then stop start fi ;; &nbSp; force-reload|reload) reload ;; configtest) configtest ;; *) echo $ " usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help| Configtest} " RETVAL=2 esac exit $RETVAL
Modify file Permissions:
chmod +x/etc/init.d/nginx
To view Nginx services:
Chkconfig--list nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off
This article from "It struggle" blog, declined reprint!
CentOS 6.5 Source Installation Nginx