CentOS7通過yum方式安裝Nginx

  1. 安裝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
  1. 啟動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>
  1. 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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容