nginx安裝配置

nginx安裝配置

  • 下載
    wget -c https://nginx.org/download/nginx-1.12.1.tar.gz
  • 安裝
    • 解壓
    tar -zxvf nginx-1.12.1
    • 配置(採用的都是默認配置,詳細配置可查詢nginx官網)
    ./configure
    執行完報錯以下
    ./configure: error: the HTTP rewrite module requires the PCRE library.
    You can either disable the module by using --without-http_rewrite_module
    option, or install the PCRE library into the system, or build the PCRE library
    statically from the source with nginx by using --with-pcre=<path> option.
    缺乏pcre包,安裝pcre包
    yum -y install pcre-devel
    再次執行nginx配置
    ./configure
    執行完後再次報錯以下
    ./configure: error: the HTTP gzip module requires the zlib library.
    You can either disable the module by using --without-http_gzip_module
    option, or install the zlib library into the system, or build the zlib library
    statically from the source with nginx by using --with-zlib=<path> option.
    缺乏zlib包,安裝zlib包
    yum -y install zlib zlib-devel
    再次執行nginx配置
    ./configure --with-http_ssl_module
    執行完後報錯
    ./configure: error: SSL modules require the OpenSSL library.
    You can either do not enable the modules, or install the OpenSSL library
    into the system, or build the OpenSSL library statically from the source
    with nginx by using --with-openssl=<path> option.
    缺乏OpenSSL包,安裝該包
    yum -y install openssl openssl-devel
    再次執行nginx配置
    ./configure --with-http_ssl_module
    再也不報錯,執行成功
    • 編譯
    make
    • 安裝
      make install
  • 測試
    ps -ef|grep nginx
    以下運行成功
    root     28023     1  0 15:36 ?        00:00:00 nginx: master process ./sbin/nginx -c conf/nginx.conf
    nobody   28024 28023  0 15:36 ?        00:00:00 nginx: worker process
    root     28717 15784  0 15:45 pts/1    00:00:00 grep --color=auto nginx
    開放端口80
    firewall-cmd --add-port=80/tcp --permanent
    firewall-cmd --reload
    頁面顯示 Welcome to nginx!
相關文章
相關標籤/搜索