Lnmp compiled and installed Nginx1.8.0 stable (stable version)
1, yum install Nginx to want to the living environment, that is, the library file
Yum-y install make gcc gcc-c++ glibc glibc-devel automake autoconf libtool make
2. Add system users to Nginx
Useradd-s/sbin/nologin-m-R nginx
3, decompression installation nginx1.8.0
Tar XF nginx-1.8.0.tar.gz cd nginx-1.8.0./configure--prefix=/usr/local/nginx1.8--sbin-path=/usr/local/nginx1.8/ Nginx--conf-path=/usr/local/nginx1.8/conf/nginx.conf--pid-path=/usr/local/nginx1.8/pid/nginx.pid--with-http_ Ssl_module--user=nginx--group=nginx--with-pcre=. /pcre-8.37--with-zlib=. /zlib-1.2.8--with-http_ssl_module--with-openssl=. /openssl-1.0.1p Makemake Installecho $?
4, the Nginx server startup program parameters detailed description
/usr/local/nginx-1.8.0/sbin/nginx-t
Nginx Related parameters
-?,-H:this Help
-v:show Version and exit
-v:show version and configure options then exit
-t:test Configuration and exit
-q:suppress non-error messages during configuration testing
-S signal:send signal to a master process:stop, quit, reopen, reload
-P prefix:set Prefix path (default:/usr/local/nginx-1.8.0/)
-C filename:set configuration file (default:conf/nginx.conf)
-G Directives:set Global directives out of configuration file
5, the installation process problems
./configure:error:the HTTP gzip module requires the Zlib library. You can either disable the module by using--without-http_gzip_moduleoption, or install the Zlib library into the system, or build the zlib librarystatically from the source with Nginx by using--with-zlib=<path> option. Solution: Tar XF zlib-1 .2.8.tar.gz CD zlib-1.2.8./configure--prefix=/usr/local/zlib1.2.8 make && make INSTALLCD nginx-1.8.0./ Configure--prefix=/usr/local/nginx-1.8.0--user=nginx--group=nginx--with-http_ssl_module--with-openssl=/usr/ local/openssl/--with-zlib=/usr/local/zlib1.2.8/
3. Configure Nginx self-boot file
3.1 Adding Nginx system configuration Files
vim/etc/sysconfig/nginx# Configuration file for the Nginx service. nginx=/usr/local/nginx-1.8.0/sbin/nginxconffile=/usr/local/nginx-1.8.0/conf/nginx.conflockfile=/var/lock/ Subsys/nginx
3.2 Configuring the Nginx server to boot from the boot file
Vim/etc/rc.d/init.d/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:/usr/local/nginx-1.8.0/conf/nginx.conf
# config:/etc/sysconfig/nginx
# Pidfile:/var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source Networking configuration.
. /etc/sysconfig/network
# Check that networking are up.
["$NETWORKING" = "no"] && exit 0
nginx= "/usr/local/nginx-1.8.0/sbin/nginx"
prog=$ (basename $nginx)
Nginx_conf_file= "/usr/local/nginx-1.8.0/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 '-'
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 >/dev/null 2>&1 | | Return $?
Stop
Sleep 1
Start
}
Reload () {
Configtest >/dev/null 2>&1 | | 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 "$" in
Start
Rh_status_q && Exit 0
$
;;
Stop
Rh_status_q | | Exit 0
$
;;
Restart|configtest)
$
;;
Reload
Rh_status_q | | Exit 7
$
;;
Force-reload)
Force_reload
;;
Status
Rh_status
;;
Condrestart|try-restart)
Rh_status_q | | Exit 0
;;
*)
echo $ "Usage: $ {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
Exit 2
Esac
3.3 Setting up and checking Nginx service in the system
#增加nginx服务. Chkconfig ensure that each run level has a start (S) or Kill (K) entry. If missing, it is automatically created from the default init script
Chkconfig--add Nginx
#设置nginx在开启时候的运行级别的状态, the default level is 2, 3, 4, 5
Chkconfig Nginx on
#检查nginx的启动级别
Chkconfig--list | grep Nginxnginx 0:off1:off2:on3:on4:on5:on6:of
3.4 Test Nginx Start-up service:
Default configuration syntax for 3.4.1, test nginx:
[Email protected] ~]# service nginx configtestnginx:the configuration file/usr/local/nginx-1.8.0/conf/nginx.conf Syntax is oknginx:configuration file/usr/local/nginx-1.8.0/conf/nginx.conf test is successful
3.4.2, start Nginx service
[[Email protected] ~]# service Nginx startstarting nginx: [OK]
3.4.3, restart Nginx service
[[Email protected] ~]# service Nginx restartstopping nginx: [OK]starting ng INX: [OK]
3.4.4, using reload smooth restart Nginx
[[Email protected] ~]# service Nginx reloadreloading nginx: [OK]
3.4.5, viewing the status of Nginx
[[Email protected] ~]# service Nginx statusnginx (PID 46887 46866) is running ...
3.4.6, close nginx and view nginx status
[[Email protected] ~]# service Nginx stopstopping nginx: [OK][[email Protec Ted] ~]# service Nginx Statusnginx is stopped[[email protected] ~]#
Above is the installation and deployment process of nginx in LNMP environment, if you have doubts, please contact qq:877306754
This article is from the "Cowboy" blog, make sure to keep this source http://fangniuwa.blog.51cto.com/10209030/1749930
Nginx1.8.0 Stable (stable version) based on LNMP compiled and installed under CentOS6.5 environment