center os部署Nginx
1.下载包
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz
wget http://nginx.org/download/nginx-1.8.0.tar.gz
2.解压
tar -zxvf pcre-8.33.tar.gz
tar -zxvf openssl-1.0.1j.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
tar -zxvf nginx-1.8.0.tar.gz
3.安装
安装 pcre
cd pcre-8.33
./configure
make && make install
安装openssl
cd openssl-1.0.1j
./config
./Configure
make && make install
安装 zlib
cd zlib-1.2.11
./configure
make && make install
安装 nginx(包括ssl-http)
cd nginx-1.8.0
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--prefix=/usr/local/nginx --with-http_stub_status_module \
--with-http_ssl_module \
--with-openssl=/software/nginx/openssl-1.0.1j \
make && make install
4.修改配置文件
cd /usr/local/nginx/conf/
vim nginx.conf
HTTP server
HTTPS server
重要参数介绍
listen:端口
server_name:ip、域名
proxy_pass:转发到服务器
ssl_certificate:证书pem文件(绝对路径)
ssl_certificate_key:证书key(绝对路径)
5.启动nginx
./sbin/nginx
ps -ef | grep nginx查看是否启动成功
启动失败可查看日志
安装目录默认安装在 /usr/local/nginx 目录下
遇到的问题
1、pcre插件未安装
2、443端口未开放
Nginx命令
1、nginx启动命令 ./nginx
2、nginx停止命令 ./nginx -s stop
3、nginx重启命令 ./nginx -s reload