$ yum -y install gcc gcc-c++ autoconf automake
$ yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
pcre: 用来作地址重写的功能。
zlib:nginx 的gzip模块,传输数据打包,省流量(但消耗资源)。
openssl:提供ssl加密协议。
[root@localhost src] wget https://nchc.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz
[root@localhost src]# tar -zxf pcre-8.40.tar.gz
[root@localhost src]# cd pcre-8.40
[root@localhost pcre-8.40]# ./configure --prefix=/usr/local/pcre
[root@localhost pcre-8.40]# make && make install
[root@localhost src]# wget http://zlib.net/zlib-1.2.11.tar.gz
[root@localhost src]# tar -zxf zlib-1.2.11.tar.gz
[root@localhost src]# cd zlib-1.2.11
[root@localhost zlib-1.2.11]# ./configure --prefix=/usr/local/zlib
[root@localhost zlib-1.2.11]# make && make install
[root@localhost src]# wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz
[root@localhost src]# tar -zxf openssl-1.1.0e.tar.gz
[root@localhost src]# cd openssl-1.1.0e
[root@localhost openssl-1.1.0e]# ./config --prefix=/usr/local/openssl
[root@localhost openssl-1.1.0e]# make && make install
[root@localhost openssl-1.1.0e]# export PATH=$PATH:/usr/local/openssl/bin
[root@localhost openssl-1.1.0e]# source /etc/profile
[root@localhost src]# yum -y install gd-devel
[root@localhost src]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
[root@localhost src]# tar -zxf nginx-1.12.0.tar.gz
[root@localhost src]# cd nginx-1.12.0
[root@localhost src]# groupadd nginx
[root@localhost src]# useradd -g nginx -s /bin/false nginx
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_sub_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_secure_link_module \
--with-mail \
--with-mail_ssl_module \
--with-pcre=/usr/local/src/pcre-8.40 \
--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-openssl=/usr/local/src/openssl-1.1.0e
./configure --help
[root@localhost nginx-1.12.0]# make && make install
要以这种方式启动才行,某次我以service方式启动,结果报错了:
[error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"
[root@localhost nginx-1.12.0]# /usr/local/nginx/sbin/nginx
将/usr/local/nginx/sbin/nginx加入到rc.local文件末尾,请确保rc.local有可执行权限,一般linux默认是不会给rc.local可执行权限的
在/etc/rc.d/init.d/下面增加一个脚本,名称 nginx,脚本内容查看这里
1、启动 service nginx start
2、停止 service nginx stop
3、重启 service nginx restart
4、重载配置 service nginx reload
http://www.ttlsa.com/nginx/use-nginx-proxy/
解决nginx下php-fpm不记录php错误日志的办法