一、说明
1、linux用的是CentOS7
2、ng版本是1.9.1
二、安装
1、下载安装包
https://nginx.org/download/
2、上传到服务器
3、解压
tar -zxvf nginx-1.9
说明: tab键补全
4、进入
cd nginx-1.9
说明: tab键补全
5、安装依赖
yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
6、确定需要的模块并构建编译文件Makefile
./configure \--prefix=/usr/local/nginx \--with-stream \--with-http_ssl_module \--conf-path=/usr/local/nginx/conf/nginx.conf \--pid-path=/usr/local/nginx/conf/nginx.pid \--lock-path=/var/lock/nginx.lock \--error-log-path=/var/logs/nginx/error.log \--http-log-path=/var/logs/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
7、编译
make & make install
8、手动创建client目录
sudo mkdir -p /var/temp/nginx
9、完成
说明1:http 与 stream模块不能监听相同端口
~~
三、启动与重启
1、搜索nginx所在目录
find / -name nginx
2、启动
1)默认启动
/usr/local/nginx/nginx -s start
2)指定配置文件
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
~~
3、重启
1)默认重启
/usr/local/nginx/nginx -s reload
2)指定配置文件重启
/usr/local/nginx/sbin/nginx -s reload -c /usr/local/nginx/conf/nginx.conf
3)查看安装目录
rpm -q nginx -l
~~