centos nginx 安裝 流程

 

  1. 進入官網下載ngnix

 

可以點擊下載也可以右鍵複製鏈接下載建議使用右鍵複製鏈接下載

Wget 鏈接地址

 

2,開始安裝前下載安裝依賴

yum -y install pcre pcre-devel

yum -y install openssl openssl-devel

yum -y install gcc-c++ autoconf automake

yum install -y zlib-devel

yum -y install libxml2 libxml2-dev

yum -y install libxslt-devel

yum -y install gd-devel

yum -y install perl-devel perl-ExtUtils-Embed

yum -y install GeoIP GeoIP- devel GeoIP-data  

 

 

3、建用戶及用戶組

groupadd nginx

useradd -g nginx nginx

4、擴展說明

1、指定已安裝的第三方模塊目錄,比如https的支持等 ** --add-module=/usr/local/nginx/extra/modules --add-dynamic-module=/usr/local/nginx/extra/dynamic-modules **

如果沒加這兩個參數可以後期重新./configuremake不需要make install因爲會覆蓋 【參考文章:https://blog.csdn.net/cxm19881208/article/details/64441890 

2google優化工具: *--with-google_perftools_module * 需要安裝libunwind纔可以,平時開發環境可以不用打開此項,裝起來有點麻煩,需要的自行google或度娘

3、編譯安裝遇到了問題? 參考文章:https://tieba.baidu.com/p/4568751779?red_tag=0918228242

二、編譯安裝

1./configure(建議./configure --help看一遍)

./configure --prefix=/usr/local/nginx \
  --sbin-path=/usr/local/sbin/nginx \
  --modules-path=/usr/local/nginx/modules \
  --conf-path=/usr/local/nginx/etc/nginx.conf \
  --error-log-path=/usr/local/nginx/error.log \
  --pid-path=/usr/local/nginx/run/nginx.pid \
  --lock-path=/usr/local/nginx/lock/nginx.lock \
  --user=nginx \
  --group=nginx \
  --with-select_module \
  --with-poll_module \
  --with-threads \
  --with-file-aio \
  --with-http_ssl_module \
  --with-http_v2_module \
  --with-http_realip_module \
  --with-http_addition_module \
  --with-http_xslt_module \
  --with-http_xslt_module=dynamic \
  --with-http_image_filter_module \
  --with-http_image_filter_module=dynamic \
  --with-http_geoip_module \
  --with-http_geoip_module=dynamic \
  --with-http_sub_module \
  --with-http_dav_module \
  --with-http_flv_module \
  --with-http_mp4_module \
  --with-http_gunzip_module \
  --with-http_gzip_static_module \
  --with-http_auth_request_module \
  --with-http_random_index_module \
  --with-http_secure_link_module \
  --with-http_degradation_module \
  --with-http_slice_module \
  --with-http_stub_status_module \
  --http-log-path=/usr/local/nginx/access.log \
  --http-client-body-temp-path=/usr/local/nginx/http/client-body \
  --http-proxy-temp-path=/usr/local/nginx/http/proxy \
  --http-fastcgi-temp-path=/usr/local/nginx/http/fastcgi \
  --http-uwsgi-temp-path=/usr/local/nginx/http/uwsgi \
  --http-scgi-temp-path=/usr/local/nginx/http/scgi \
  --with-mail \
  --with-mail=dynamic \
  --with-mail_ssl_module \
  --without-mail_pop3_module \
  --without-mail_imap_module \
  --without-mail_smtp_module \
  --with-stream \
  --with-stream=dynamic \
  --with-stream_ssl_module \
  --with-stream_realip_module \
  --with-stream_geoip_module \
  --with-stream_geoip_module=dynamic \
  --with-stream_ssl_preread_module \
  --with-cpp_test_module \
  --with-compat \
  --with-debug

2、看到如下信息說明編譯成功

Configuration summary
  + using threads
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

 
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/sbin"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/etc"
  nginx configuration file: "/usr/local/nginx/etc/nginx.conf"
  nginx pid file: "/usr/local/nginx/run"
  nginx error log file: "/usr/local/nginx/logs"
  nginx http access log file: "/usr/local/nginx/http/log"
  nginx http client request body temporary files: "/usr/local/nginx/http/client-body-temp-path"
  nginx http proxy temporary files: "/usr/local/nginx/http/proxy-temp-path"
  nginx http fastcgi temporary files: "/usr/local/nginx/http/fastcgi-temp-path"
  nginx http uwsgi temporary files: "/usr/local/nginx/http/uwsgi-temp-path"
  nginx http scgi temporary files: "/usr/local/nginx/http/scgi-temp-path"

3、編譯安裝

make &make install

4、看到如下輸出信息安裝完成

make[1]: Leaving directory `/usr/local/src/nginx-1.14.0'
[1]+  Done                    make

5、由於./configure的時候已經制定了sbinpath,所以不要再人爲軟鏈到sbin,如果which nginx找不到,請自行加入ln -s軟鏈

6、測試一下並尋找nginx的配置文件位置

nginx -t

7、檢查

id nginx

8、指定配置文件

nginx -c /usr/local/nginx/etc/nginx.conf

9、平滑重啓

nginx -s reload

10、可能報錯沒什麼目錄,根據提示建一個就好,上面configure的時候配置httpclient-body

mkdir -p /usr/local/nginx/http/client-body
nginx -s reload

 

 

 

參看文章:https://my.oschina.net/cxgphper/blog/2050510

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章