centos 7 nginx 安装

1、下载nginx rpm包

下载地址:http://nginx.org/packages/mainline/centos/7/x86_64/RPMS/ ,可查看所有安装包

从中如下载:

wget http://nginx.org/packages/mainline/centos/7/x86_64/RPMS/nginx-1.11.5-1.el7.ngx.x86_64.rpm

2、安装nginx

rpm -ivh nginx-1.11.5-1.el7.ngx.x86_64.rpm

3、检查是否安装成功

nginx -v

输入此命令后显示nginx版本信息

4、开启服务

查看服务状态命令:systemctl status nginx.service

开启/停止/重启服务命令:systemctl start/stop/restart nginx.service 如开启服务:systemctl start nginx.service

开机启动/取消命令:systemctl enable/disable nginx.service  开机启动:systemctl enable nginx.service

5、查看服务是否正常

打开浏览器,输入地址:http://localhost  会显示nginx欢迎界面

*面情况下,可以通过telnet loaclhost 80(telnet 127.0.0.1  80) 查看80端口是否开启(telnet没有安装 可以通过yum install telnet),然后输入任意字符比如"d",telnet 窗口返回服务器信息

[root@localhost /]# telnet localhost 80
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
d
HTTP/1.1 400 Bad Request
Server: nginx/1.11.5
Date: Thu, 03 Nov 2016 02:20:49 GMT
Content-Type: text/html
Content-Length: 173
Connection: close <html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.11.5</center>
</body>
</html>
Connection closed by foreign host.

在信息输出http头信息里面含Server: nginx/1.11.5,表示nginx已经提供服务

上一篇:Spring注解实例


下一篇:python Unable to find vcvarsall.bat 错误