标题 | 说明 |
---|---|
服务器版本 | Centos7 x64 |
nginx版本 | 1.19.6 |
作者 | walton |
mkdir /usr/dev/nginx
cd /usr/dev/nginx
wget http://nginx.org/download/nginx-1.19.6.tar.gz
或者
在 http://nginx.org/download/ 直接下载对应版本安装包上传到服务器文件夹内
Q: 如何获取下载版本?
A: 在此网站中(http://nginx.org/download/)获取版本,然后修改wget命令后的版本号
tar -zxvf nginx-1.19.6.tar.gz
cd /nginx-1.19.6
[root@fanzyx nginx-1.19.6]# ./configure --prefix=/usr/local/nginx
出现如下错误
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
需要安装openssl,执行以下命令
[root@fanzyx nginx-1.19.6]# yum -y install openssl openssl-devel
再次执行命令
[root@fanzyx nginx-1.19.6]# ./configure --prefix=/usr/local/nginx
当前目录下执行make命令,该命令是将源文件编译为可执行文件
[root@fanzyx nginx-1.19.6]# make
编译成功,如图所示、
将编译后的文件复制到设置的安装目录
[root@fanzyx nginx-1.19.6]# make install
为nginx指定配置文件路径并启动
[root@fanzyx nginx-1.19.6]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
方法一:
[root@fanzyx nginx-1.19.6]# /usr/local/nginx/sbin/nginx -s stop
方法二:
查询nginx进程
ps -ef | grep nginx
[root@fanzyx nginx-1.19.6]# ps -ef | grep nginx
root 15038 1 0 11:44 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 15039 15038 0 11:44 ? 00:00:00 nginx: worker process
root 15084 9881 0 11:45 pts/0 00:00:00 grep --color=auto nginx
在进程列表中带master的进程就是主进程
kill -QUIT 主进程号
eg: kill -QUIT 15038
再次执行查询命令发现主进程已消失
[root@fanzyx nginx-1.19.6]# kill -QUIT 15038
[root@fanzyx nginx-1.19.6]# ps -ef | grep nginx
root 15271 9881 0 11:50 pts/0 00:00:00 grep --color=auto nginx
[root@fanzyx nginx-1.19.6]#
安装路径 -s reload
/usr/local/nginx/sbin/nginx -s reload
安装路径 -t
/usr/local/nginx/sbin/nginx -t
如下所示配置成功
[root@fanzyx nginx-1.19.6]# /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
[root@fanzyx nginx-1.19.6]#
原文:https://www.cnblogs.com/fanzyx/p/14257982.html