CentOS-6.8 安装 Nginx

8 篇文章 0 订阅
CentOS-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
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
两种方式都可以


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值