## 安装Nginx
打开nginx官方网站的下载页`http://nginx.org/en/download.html`:
:-: ![](https://box.kancloud.cn/630a4334a6ca7dd71553674dc0012070_553x261.jpg)
拉倒页面最下端,这里是预编译包,我们选择稳定版(stable version)nginx-1.14.0安装,点击进去:
:-: ![](https://box.kancloud.cn/5bd0dcc1de8802352f33f7a07fe79378_828x272.jpg)
我们按照说明,创建nginx的repo文件
~~~
[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
~~~
内容如下:
~~~
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
~~~
好了,可以安装nginx了
~~~
[root@localhost ~]# yum install nginx -y
~~~
瞬间就安装完了,查看一下版本:
~~~
[root@localhost ~]# nginx -v
~~~
返回:
~~~
nginx version: nginx/1.14.0
~~~
版本正确,看看nginx服务的状态:
~~~
[root@localhost ~]# systemctl status nginx.service
~~~
返回:
~~~
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: http://nginx.org/en/docs/
~~~
服务没启动,启动它:
~~~
[root@localhost ~]# systemctl enable nginx.service
[root@localhost ~]# systemctl start nginx.service
[root@localhost ~]# systemctl status nginx.service
~~~
返回:
~~~
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2018-08-15 11:40:14 CST; 9s ago
Docs: http://nginx.org/en/docs/
Process: 2095 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 2096 (nginx)
CGroup: /system.slice/nginx.service
├─2096 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─2097 nginx: worker process
Aug 15 11:40:14 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
Aug 15 11:40:14 localhost.localdomain systemd[1]: Started nginx - high performance web server.
~~~
Nginx启动了,小绿灯好像更亮了……
给虚拟机拍个快照保存下成果