Source Installation Nginx
The three dependencies of Nginx are Pcre, OpenSSL, zlib, respectively.
Where compiling pcre requires:
yum install gcc gcc-c++ pcre-devel
Download the source Package
官网下载最新版即可:http://www.pcre.org/http://www.openssl.orghttp://www.zlib.net/http://nginx.org
Note: Here pcre can only be 8.0+,pcre2 not supported
Will error:
`libpcre.la'. Stop.
In addition to Pcre I use the latest stable version, give me a pcre source package:
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
Compile
There is no need to compile the installation separately, directly into the extracted Nginx directory to execute
Assume that files are placed in the/home directory
./configure --prefix=/data/nginx --with-http_realip_module \--with-http_sub_module \--with-http_flv_module \--with-http_dav_module \--with-http_gzip_static_module \--with-http_stub_status_module \--with-http_addition_module \--with-pcre=/home/pcre2-10.00 \--with-openssl=/home/openssl-1.0.2a \--with-http_ssl_module \--with-zlib=/home/zlib-1.2.8
Note that the green three is the directory of the specified source code, not the installation directory, because this method is co-compiled, do not need to pre-compile installation Pcre,ssl,zlib
Then there is:
makemake install
Perform
In accordance with the above installation method, Nginx installed in the/data/nginx
./data/nginx/sbin/nginx -c /data/nginx/conf/nginx.conf#因为它需要指定配置文件才能运行,执行这条配置文件没有返回,建议使用脚本控制
The script is as follows
#!/bin/sh# config:/usr/local/nginx/conf/nginx.confNginx_path="/data/nginx"Nginx_pid="/data/nginx/logs/nginx.pid"# Source function library.. /etc/rc.d/init.d/functions# Source Networking configuration.. /etc/sysconfig/network# Check that networking are up.[${networking}="No"] &&Exit0[-X$nginx _path/sbin/nginx] | |Exit0Retval=0prog="Nginx"Start() {# Start daemons.if[- e$nginx _pid -A! -Z$nginx _pid]; ThenEcho"Nginx already running ..."Exit1fiif[- e$nginx _path/CONF/NGINX.CONF]; ThenEcho-N $"Starting $prog:"$nginx _path/sbin/nginx-c$nginx _path/conf/nginx.conf & retval=$? [$RETVAL-eq0] && {touch/var/lock/subsys/$progSuccess $"$prog"}EchoElseRetval=1fireturn$RETVAL}# Stop daemons.Stop() {Echo-N $"Stopping $prog:"Killproc- DTen$NIGX _path/sbin/nginx retval=$?Echo[$RETVAL=0] && RM- F$nginx _pid/var/lock/subsys/$prog}# See how we were called. Case"$"inchStart) Start; stop) stop;; RECONFIGURE) stop start;; Status) status$progRetval=$? ;; *)Echo$"Usage: $ {start|stop|reconfigure|status}"Exit1EsacExit$RETVAL
If the script is named nginx.sh
Then you can:
./nginx.sh status|stop|start....
Configuration of the agent
The above describes the Nginx reverse proxy (and optimization), including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.