部署
- 官网下载,最新linux下稳定版本 nginx-1.18.0
- 执行以下命名,解压nginx
tar -zxvf nginx-1.18.0.tar.gz
- 在安装目录下,执行以下命令安装nginx
./configure --prefix=/usr/local/nginx (在/usr/local/nginx目录安装)
make
make install
- 测试nginx是否安装成功:在/usr/local/nginx目录下执行 ./sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
问题
- ./configure: error: the HTTP rewrite module requires the PCRE library.
没有安装nginx需要的PCRE 库
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel 安装nginx需要的库
常用命令
./nginx -s stop 关闭nginx
./nginx -s quit 关闭nginx,有连接时会等连接请求完成再关闭
./nginx -s reload 重启nginx
./nginx -t 检查nginx配置文件
./nginx -h 帮助信息
./nginx -c filename 指定配置文件启动