一、 安装编译工具及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
二、 下载nginx
https://nginx.org/en/download.html

三、 编译安装
./configure --prefix=/usr/local/nginx/
make && make install
四、 常用命令
- 找出nginx 进程号
ps -ef | grep nginx
[root@iZhp3349o7pntezql2q5puZ nginx-1.18.0]# ps -ef |grep nginx
root 13579 11009 0 23:38 pts/0 00:00:00 grep --color=auto nginx
root 21819 1 0 Apr03 ? 00:00:00 nginx: master process ./sbin/nginx
root 21820 21819 0 Apr03 ? 00:00:00 nginx: worker process
- 测试配置文件
./nginx -t
[root@iZhp3349o7pntezql2q5puZ nginx]# pwd
/usr/local/nginx
[root@iZhp3349o7pntezql2q5puZ 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
- 启动nginx
./nginx
指定配置文件启动
./nginx -c /user/local/nginx/conf/nginx.conf
- 关闭nginx
立即关闭
kill -TERM 主pid
kill -9 主pid
- 优雅关闭
kill -QUIT 主pid
- 重启
./ningx -s reload
[root@iZhp3349o7pntezql2q5puZ nginx]# pwd
/usr/local/nginx
[root@iZhp3349o7pntezql2q5puZ 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
[root@iZhp3349o7pntezql2q5puZ nginx]# ./sbin/nginx -s reload
[root@iZhp3349o7pntezql2q5puZ nginx]#
- 查看nginx 版本号
./nginx -v
[root@iZhp3349o7pntezql2q5puZ nginx]# ./sbin/nginx -v
nginx version: nginx/1.10.2
[root@iZhp3349o7pntezql2q5puZ nginx]#
- 查看nginx 版本号及编译信息
./nginx -V
[root@iZhp3349o7pntezql2q5puZ nginx]# pwd
/usr/local/nginx
[root@iZhp3349o7pntezql2q5puZ nginx]# ./sbin/nginx -V
nginx version: nginx/1.10.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_dav_module --with-file-aio --with-http_dav_module --add-module=../ngx_devel_kit-0.2.19/ --add-module=../lua-nginx-module-0.10.13/
[root@iZhp3349o7pntezql2q5puZ nginx]#
网友评论