############## 安装OpenSSL ######################
wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz
tar zxvf openssl-1.0.2l.tar.gz
cd openssl-1.0.2l/
./config --prefix=/opt/local/openssl ;
make && sudo make install
################ 安装PCRE ########################
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
tar zxvf pcre-8.41.tar.gz
./configure --prefix=/opt/local/pcre-8.41 ;
make && sudo make install
################ 安装Nginx ########################
# 配置nginx (--with-pcre、--with-openssl 的路径是源码路径)
./configure --prefix=/opt/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-pcre=../pcre-8.41 --with-openssl=../openssl-1.0.21
# 1.查看帮助
$ /opt/local/nginx/sbin/nginx -h
# 2.检查配置文件正确性
$ sudo /opt/local/nginx/sbin/nginx -t
# 3.查看进程号
$ cat /opt/local/nginx/logs/nginx.pid
23214
$ ps -ef | grep "nginx: master process" | grep -v ‘grep‘ | awk -F ‘ ‘ ‘{print $2}‘
23214
# 4.重新加载配置
sudo kill -HUP `cat /opt/local/nginx/logs/nginx.pid`
# 5.赋予普通用户操作权限
sudo chmod u+s /opt/local/nginx/sbin/nginx
# 6.停止nginx
/opt/local/nginx/sbin/nginx -s stop
# 处理完请求后,关闭进程
$ kill -QUIT ` cat /opt/local/nginx/logs/nginx.pid `