zoukankan      html  css  js  c++  java
  • linux上编译nginx 实现网页开发

    wget http://nginx.org/download/nginx-1.16.1.tar.gz
    # 解压
    tar -xzf nginx-1.16.1.tar.gz
    cd nginx-1.16.1
    # yum升级
    yum update
    # yum安装依赖
    yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
    ./configure --prefix=/usr/local/nginx
    # make
    make
    make install

    find / -name nginx
    可以看到/usr/local/nginx存在
    # cd到刚才配置的安装目录/usr/loca/nginx/

    ./sbin/nginx -t

    正确是这样的:
    [root@ecs-PicYc nginx]# ./sbin/nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

    # 启动服务

    ./nginx

    #查看服务状态

    ps -ef | grep nginx

    #查看服务器端口状态

    netstat -apn

    #验证下服务的请求

    curl localhost:80

    正确的返回结果

    [root@ecs-PicYc ~]# curl localhost:80
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
        body {
             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>

    这个返回是  /usr/local/nginx/html/index.html 这个目录下的html文件

     #查看是否开放80 端口

    [root@ecs-PicYc ~]# firewall-cmd --query-port=80/tcp
    no

    #开放端口

    [root@ecs-PicYc ~]# firewall-cmd --add-port=80/tcp --permanent
    success

    #重启防火墙

    systemctl restart firewalld





  • 相关阅读:
    了解大数据的特点、来源与数据呈现方式
    结对项目
    第四次作业
    阅读《构建之法》1-5章有感
    iOS 应用如何完全支持 IPv6-ONLY 网络?
    丙申年把真假美猴王囚禁在容器中跑 ASP.NET Core 1.0
    ASP.NET Core 1.0 部署 HTTPS (.NET Framework 4.5.1)
    推荐一款跨平台的 Azure Storage Explorer
    更改 Skype for Business Online 的 Sip 地址以匹配UPN
    C# 计算字符串在控制台中的显示长度
  • 原文地址:https://www.cnblogs.com/132818Creator/p/14782360.html
Copyright © 2011-2022 走看看