1.根據(jù)nginx 官網(wǎng)安裝步驟來(lái)安裝 http://nginx.org/en/linux_packages.html
新建文件 vi /etc/yum.repos.d/nginx.repo
里面輸入一下內(nèi)容
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
里面OS 替換為centos OSRELEASE替換為7 $basearch 替換為x86_64
2.查看自己系統(tǒng)版本
rpm -qa | grep centos-release
3.通過(guò)yum install nginx 來(lái)安裝nginx
4.啟動(dòng)nginx 命令
systemctl start nginx
5.查看nginx是否啟動(dòng)
netstat -ntl
如果看到這樣說(shuō)明啟動(dòng)成功
6.本地測(cè)試
curl -i localhost
如果顯示如下
HTTP/1.1 200 OK
Server: nginx/1.14.0
Date: Wed, 09 May 2018 07:47:07 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 17 Apr 2018 15:48:00 GMT
Connection: keep-alive
ETag: "5ad61730-264"
Accept-Ranges: bytes
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a >nginx.org</a>.
Commercial support is available at
<a >nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
說(shuō)明nginx安裝成功
6.防火墻端口開(kāi)發(fā)
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload
7.如果是阿里云服務(wù)器還需要去管理后臺(tái)安全組去添加開(kāi)放80端口