Install nginx

RHEL/CentOS
Install the prerequisites:

sudo yum install yum-utils

To set up the yum repository, create the file named /etc/yum.repos.d/nginx.repo with the following contents:

vi /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

By default, the repository for stable nginx packages is used. If you would like to use mainline nginx packages, run the following command:

sudo yum-config-manager --enable nginx-mainline

To install nginx, run the following command:

sudo yum install nginx

When prompted to accept the GPG key, verify that the fingerprint matches 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62, and if so, accept it.

cd /etc/nginx/conf.d
vi default.conf
或者
vi /etc/nginx/nginx.conf
server {
    listen       81;
    server_name  localhost;

    location / {
        root   /data/wwwroot/m.xxx.com;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

启动:
 service nginx start
启动nginx:
nginx -c /path/to/nginx.conf
关闭nginx:
nginx -s stop  :快速停止nginx  
         quit  :完整有序的停止nginx
重启nginx:
nginx -s reload  :修改配置后重新加载生效  
nginx -s reopen  :重新打开日志文件  
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

其他的停止nginx 方式:
ps -ef | grep nginx
kill -QUIT 主进程号     :从容停止Nginx  
kill -TERM 主进程号     :快速停止Nginx  
pkill -9 nginx          :强制停止Nginx
平滑重启nginx:
kill -HUP 主进程号
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值