温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

nginx 安装方法2

发布时间:2020-07-10 15:18:49 来源:网络 阅读:447 作者:暖暖miss 栏目:建站服务器

entOS-6.8 安装 Nginx

Nginx 环境准备:

安装Nginx需要完成以下依赖的安装

1.gcc 安装:yum install gcc-c++

2.PCRE pcre-devel 安装:yum install -y pcre pcre-devel

3.zlib 安装: yum install -y zlib zlib-devel

4.OpenSSL 安装:yum install -y openssl openssl-devel

安装Nginx

1. 下载Nginx

wget -chttps://nginx.org/download/nginx-1.10.1.tar.gz

2. 解压:

tar -zxvf nginx-1.10.1.tar.gz

3. 配置:

cd nginx-1.10.1 进入nginx解压目录

./configure

4. 编译安装:

make

make install

5. 查找安装路径:

whereis nginx

启动、停止Nginx:

1. 查找nginx安装路径:whereis nginx

2. 进入nginx安装路径:cd /usr/local/nginx/sbin

3. 启动:

1. ./nginx

2. /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

两种方式都可以

4. 停止:

从容停止:kill -QUIT 19795(注意:19795是Nginx的进程号)

快速停止:kill -TERM 46968(注意:46968是Nginx的进程号)

kill -INT 46975(注意:46975是Nginx的进程号)

强制停止:pkill -9 nginx

./nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。

./nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。 

先停止再启动:./nginx -s quit; ./nginx


5. 重启:

1. 验证nginx的配置文件是否正确:

1. cd /usr/local/nginx/sbin 进入nginx的安装目录,接着执行 ./nginx -t

如果正确,会有如下的信息:

[root@localhost 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

2. /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf

如果正确会有如下信息:

[root@localhost sbin]# /usr/local/nginx/sbin/nginx

-t -c /usr/local/nginx/conf/nginx.conf

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

2. 如果配置文件正确,则可以重启:

1. ./nginx -s reload (需提前进入nginx可执行文件目录:cd /usr/local/nginx/sbin)

2. kill -HUP 46991(46991是nginx的进程号)

6. 重新加载配置文件:

当 ngin x的配置文件 nginx.conf 修改后,要想让配置生效需要重启 nginx,

使用-s reload不用先停止 ngin x再启动 nginx 即可将配置信息在 nginx 中生效

例如: ./nginx -s reload

设置Nginx开机自启动:

即在rc.local增加启动代码就可以了

查看nginx进程:

1. ps -ef |grep nginx

2.ps aux|grep nginx

两种方式都可以


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI