zoukankan      html  css  js  c++  java
  • nginx编译安装

    nginx编译安装

    开始前准备

    环境需求
    当前在centos6.7系统环境下进行的Nginx编译安装
    编译安装nginx所需要用到的系统基本库

    yum -y install wget curl gcc gcc-c++ perl
    

    nginx编译安装需要的相关包下载

    nginx源码包

    wget -c http://nginx.org/download/nginx-1.10.1.tar.gz
    

    openssl包用于ssl协议支持

    wget -c https://www.openssl.org/source/openssl-1.0.2h.tar.gz
    

    zlib包用于压缩模块

    wget -c http://zlib.net/zlib-1.2.8.tar.gz
    

    编译安装

    tar zxf nginx-1.10.1.tar.gz
    cd nginx-1.10.1
    ./configure --prefix=/usr/local/nginx-1.10.1 --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-pcre=../pcre-8.39 --with-http_realip_module --with-http_gzip_static_module --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-1.0.2h
    
    make && make install
    

    启动nginx

    查看80端口是否被启用

    netstat -ntlp |grep 80
    

    启动nginx

    /usr/local/nginx-1.10.1/sbin/nginx
    

    测试访问

    curl 127.0.0.1
    将返回如下信息,表示安装成功
    [root@bogon nginx-1.10.1]# curl 127.0.0.1   
    <!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>
    

    到这里nginx的安装过程就结束了,默认nginx支持html,要支持php访问,还需要安装php

    后话

    如果启用了iptables规则,可能要开放80端口访问

    vi /etc/sysconfig/iptables
    加入一条规则到下面位置,如下所示
    
    # Firewall configuration written by system-config-firewall
    # Manual customization of this file is not recommended.
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    COMMIT
    

    然后重启iptables
    service iptables restart

    相关的库如openssl,zlib,pcre也可以通过yum进行安装

    yum -y install zlib-devel openssl openssl-devel pcre-devel
    
  • 相关阅读:
    开发导致的内存泄露问题,运维小伙伴儿这样排查不背锅
    JVM垃圾回收器、内存分配与回收策略
    笔试编程(二) | 7种常见的排序算法解析(附实现代码)
    HBase高级特性、rowkey设计以及热点问题处理
    Geotools创建Feature的两种方式
    geotools实现追加数据到数据库
    Java连接mysql数据库经典代码
    leaflet加载高德地图和Geoserver的WMS服务
    geotools学习之连接数据库并获取数据
    LeaFlet中切片图层使用自定义坐标系
  • 原文地址:https://www.cnblogs.com/coolworld/p/5607066.html
Copyright © 2011-2022 走看看