Linux下安裝nginx

  1. 下載安裝pcre庫
    pcre是一個正則表達式庫,nginx的rewrite模塊須要依賴該庫。
    下載地址:http://www.pcre.org/nginx

    wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz
    tar -zxvf pcre-8.40.tar.gz
    cd pcre-8.40
    ./configure 
    make
    sudo make install
  2. 下載安裝nginx
    下載地址:http://nginx.org/正則表達式

    wget http://nginx.org/download/nginx-1.8.1.tar.gz
    tar -zxvf nginx-1.8.1.tar.gz
    cd nginx-1.8.1
    ./configure
    make    
    sudo make install
  3. 驗證安裝是否成功
    默認安裝路徑:/usr/local/nginx
    創建軟連接:code

    sudo ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx

    執行nginx命令驗證是否安裝成功:get

    sudo nginx -t

    安裝成功:it

    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

    若是出現以下相似錯誤:io

    nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object             file: No such file or directory

    創建相應的軟連接而後重試:test

    sudo ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 #64位系統
    sudo ln -s /lib/libpcre.so.0.0.1 /lib64/libpcre.so.1   #32位系統
相關文章
相關標籤/搜索