美文网首页
centos 安装nginx

centos 安装nginx

作者: 李桥 | 来源:发表于2018-05-09 15:48 被阅读31次

    1.根据nginx 官网安装步骤来安装 http://nginx.org/en/linux_packages.html
    新建文件 vi /etc/yum.repos.d/nginx.repo
    里面输入一下内容
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
    gpgcheck=0
    enabled=1
    里面OS 替换为centos OSRELEASE替换为7 $basearch 替换为x86_64
    2.查看自己系统版本
    rpm -qa | grep centos-release
    3.通过yum install nginx 来安装nginx
    4.启动nginx 命令
    systemctl start nginx
    5.查看nginx是否启动
    netstat -ntl

    image.png
    如果看到这样说明启动成功
    6.本地测试
    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 href="http://nginx.org/">nginx.org</a>.

    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>
    说明nginx安装成功
    6.防火墙端口开发
    firewall-cmd --permanent --zone=public --add-port=80/tcp
    firewall-cmd --reload
    7.如果是阿里云服务器还需要去管理后台安全组去添加开放80端口

    相关文章

      网友评论

          本文标题:centos 安装nginx

          本文链接:https://www.haomeiwen.com/subject/wjtorftx.html