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

验证服务
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 href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">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
停止服务
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

强制关闭
pkill nginx

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容