CentOS中安装nginx的步骤

导言

以下是在CentOS上启动Nginx时需要预先完成的任务清单:

    • centosのバージョン確認

 

    • nginxのrepositoryを用意する

 

    nginxのインストール&サービスを常駐させる

步骤

请确认CentOS的版本

[user@localhost ~]$ cat /etc/redhat-release
CentOS release 6.9 (Final)

准备一个nginx的代码库。

[nginx]
name=nginx repository
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1

安装并使nginx服务在后台运行。

安装并启动nginx。

[user@localhost ~]$ sudo yum -y --enablerepo=nginx install nginx

[user@localhost ~]$ sudo service nginx status
nginx is stopped
[user@localhost ~]$ sudo service nginx start
Starting nginx:                                            [  OK  ]

Nginx的RPM清单

将服务常驻化

[user@localhost ~]$ chkconfig --list | grep nginx
nginx           0:off   1:off   2:on    3:on    4:on    5:on    6:off
nginx-debug     0:off   1:off   2:off   3:off   4:off   5:off   6:off

[user@localhost ~]$ sudo chkconfig nginx off
[user@localhost ~]$ chkconfig --list | grep nginx
nginx           0:off   1:off   2:off   3:off   4:off   5:off   6:off
nginx-debug     0:off   1:off   2:off   3:off   4:off   5:off   6:off

[user@localhost ~]$ sudo chkconfig nginx on
[user@localhost ~]$ chkconfig --list | grep nginx
nginx           0:off   1:off   2:on    3:on    4:on    5:on    6:off
nginx-debug     0:off   1:off   2:off   3:off   4:off   5:off   6:off

闲聊

Screen Shot 0031-03-13 at 16.46.46.png
广告
将在 10 秒后关闭
bannerAds