nginx的安裝(編譯) && 經常使用配置

背景:

考慮到生產環節下,nginx的使用可能更多的須要人們去定製化一些配置(如nginx所使用的pcre版本、安裝路徑、log路徑等一些信息),因此,咱們更多的採用源代碼編譯的方式去安裝nginx進行使用。html

nginx編譯參數的解釋linux

一:mac下安裝nginx

轉自:  http://my.oschina.net/indestiny/blog/220017(轉)nginx

二:centos下安裝nginx

啓動的時候出現:c++

./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory錯誤的話,解決方案轉自:http://www.cnblogs.com/cnsanshao/p/3652510.html,即執行:ln -s /usr/local/lib/libpcre.so.1 /lib64 便可! centos

ps:個人一些軟件的版本信息:(切換到root進行install)bash

常見錯誤以及解決方案dom

1. no acceptable C compiler found in $PATHspa

    則說明缺乏GCC環境,安裝便可:yum install gcc.net

2. You need a C++ compiler for C++ supportcode

    安裝環境便可:yum install -y gcc gcc-c++

  1. pcre:pcre-8.37.tar.gz

    1. tar -zxvf pcre-8.37.tar.gz

    2. cd pcre-8.37

    3. ./configure

    4. make && make install

    5. ln -s /usr/local/lib/libpcre.so.1 /lib64/

  2. zlib-1.2.8.tar.gz

    1. tar -zxvf zlib-1.2.8.tar.gz 

    2. cd zlib-1.2.8

    3. ./configure

    4. make && make install

  3. openssl-1.0.2d.tar.gz (時間稍微久點)

    1. tar -zxvf openssl-1.0.2d.tar.gz

    2. cd openssl-1.0.2d

    3. ./config

    4. make && make install

  4. pagespeed (看我的需求)

  5. tar -zxvf  headers-more-nginx-module.tar.gz

  6. nginx-1.8.1.tar.gz

    1. tar -zxvf nginx-1.8.1.tar.gz 

    2. cd nginx-1.8.1

    3. ./configure --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --without-http_referer_module  --with-pcre=/data/soft/pcre-8.37 --with-zlib=/data/soft/zlib-1.2.8 --with-openssl=/data/soft/openssl-1.0.2d --add-module=/data/soft/headers-more-nginx-module

    4. make && make install (過程稍微久點)

    5. cd  /usr/local/nginx/sbin

    6. ./nginx -t (檢測nginx是否安裝成功)

    7. ./nginx (啓動nginx)

    8. netstat -ntlp | grep 80 (查看nginx的端口是否成功啓動)

    9. 訪問你目標主機的外網IP,出現了 『Welcome to nginx!』則說明OK!

    10. ./nginx -V ,能夠查看nginx ./configure的一些信息

    11. 若是須要從新安裝,從新 ./configure 開始便可

  7. 配置nginx.conf

    1. 防止直接用IP地址訪問nginx (若是作其它動做,自行配置便可)

      1. server {
                listen 80 default_server;
                server_name _;
                rewrite ^/(.*) https://www.abc.com redirect;
        }

         

    2.  

 

ps :

參考:

  1.  http://blog.csdn.net/hhq163/article/details/46548151

  2. http://www.cnblogs.com/dennisit/archive/2012/12/26/2834719.html

  3. http://blog.csdn.net/eric1012/article/details/6052154l(編譯的時候參數說明)

  4. http://linux.it.net.cn/e/server/nginx/2014/1218/10546.html(ngx_headers_more說明)

  5. http://www.nginx.cn/76.html(nginx.conf說明)

相關文章
相關標籤/搜索