Linux環境搭建-Nginx安裝

如果要使用FastDFS,請先安裝FastDFS再安裝nginx 避免不必要的麻煩

nginx源碼包下載(本教程採用1.16.0)(編譯模塊包含了fastDFS和ssl模塊)


 
  1. http://nginx.org/en/download.html
  2. 官網自己下載 或者使用以下命令遠程下載
  3. wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

切換至安裝目錄


 
  1. cd /usr/local

使用rz命令將包上傳至服務器


 
  1. rz

安裝依賴庫

  1. yum -y install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel

解壓安裝包

  1. tar xzvf nginx-1.16.0.tar.gz

切換到nginx目錄

  1. cd nginx-1.16.0

運行./configure

  1. ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/log/error.log --http-log-path=/usr/local/nginx/log/access.log --pid-path=/usr/local/nginx/pid/nginx.pid --lock-path=/usr/local/nginx/lock/nginx.lock --user=root --group=root --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/ngin --add-module=/usr/local/fastdfs-nginx-module/src --with-http_ssl_module --with-http_v2_module

編譯

  1. make

安裝

  1. make install

啓動ngixn

  1. 切換目錄: cd /usr/local/nginx/sbin
  2. 啓動: ./nginx
  3. 查看: ps -ef | grep nginx
  4. 測試訪問: 39.47.243.223

可能出現的問題和一些解決方案

  1. 問題:(缺少目錄)
  2. nginx: [emerg] mkdir() "/var/tmp/nginx/client/" failed (2: No such file or directory)
  3. 方案:
  4. mkdir -p /var/tmp/nginx/client
  5. 問題:(不用管它,繼續執行make -install)
  6. make[1]: Leaving directory /usr/local/nginx-1.12.1;
  7. 方案:
  8. 不用管
  9. 問題:
  10. nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
  11. 方案:
  12. 停止運行中的nginx kill -9 殺進程
  13. 修改nginx.pid生成目錄:
  14. 在conf中的nginx.conf中解開pid目錄地址
  15. pid pid/nginx.pid;//換成自己的目錄地址
  16. 執行命令:
  17. /usr/local/nginx/sbin/nginx -c/usr/local/nginx/conf/nginx.conf
  18. 然後再啓動
  19. ./nginx
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章