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/pcre 2- 10.00 --with-openssl=/home /openssl -1.0 . 2 a --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"] &&Exit 0[-X$nginx _path/sbin/nginx] | |Exit 0Retval=0prog="Nginx"Start() {# Start daemons.if[- e $nginx _pid -A! -Z$nginx _pid]; ThenEcho "Nginx already running ..."Exit 1fiif[- e $nginx _path/CONF/NGINX.CONF]; Then Echo-N $"Starting $prog:" $nginx _path/sbin/nginx-c$nginx _path/conf/nginx.conf & retval=$? [$RETVAL -eq 0] && {touch/var/lock/subsys/$progSuccess $"$prog"}EchoElseRetval=1fireturn $RETVAL}# Stop daemons.Stop() {Echo-N $"Stopping $prog:"Killproc- D Ten $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}" Exit 1EsacExit $RETVAL
If the script is named nginx.sh
Then you can:
./nginx.sh status|stop|start....
Configuration of the agent
Nginx reverse proxy (and optimization)