- 安裝yum源
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum info nginx
yum install -y nginx
- 啟動nginx
systemctl start nginx.service
nginx -v
回顯
nginx version: nginx/1.16.0
驗(yàn)證服務(wù)
curl -i localhost
回顯
HTTP/1.1 200 OK
Server: nginx/1.16.0
Date: Thu, 11 Jul 2019 17:25:58 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 23 Apr 2019 14:36:26 GMT
Connection: keep-alive
ETag: "5cbf22ea-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>.<br/>
Commercial support is available at
<a >nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
- nginx配置文件位置在/etc/nginx/
[root@node0 ~]# ll /etc/nginx/
total 36
drwxr-xr-x. 2 root root 26 Jul 12 01:13 conf.d
-rw-r--r--. 1 root root 1007 Apr 23 22:36 fastcgi_params
-rw-r--r--. 1 root root 2837 Apr 23 22:36 koi-utf
-rw-r--r--. 1 root root 2223 Apr 23 22:36 koi-win
-rw-r--r--. 1 root root 5231 Apr 23 22:36 mime.types
lrwxrwxrwx. 1 root root 29 Jul 12 01:13 modules -> ../../usr/lib64/nginx/modules
-rw-r--r--. 1 root root 643 Apr 23 22:34 nginx.conf
-rw-r--r--. 1 root root 636 Apr 23 22:36 scgi_params
-rw-r--r--. 1 root root 664 Apr 23 22:36 uwsgi_params
-rw-r--r--. 1 root root 3610 Apr 23 22:36 win-utf
編輯主配置文件
vim /etc/nginx/conf.d/default.conf
重新加載配置
nginx -s reload
停止服務(wù)
nginx –s stop
檢查配置文件
nginx -t
回顯
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
強(qiáng)制關(guān)閉
pkill nginx