1、官方自行下載nginx源碼
2、切換到解壓后的nginx目錄中執行:
./configure --prefix=/opt/demo/nginx --add-module=/home/fastdfs-nginx-module/src??--with-http_stub_status_module --with-http_ssl_module
參數說明:
--prefix 用于指定nginx編譯后的安裝目錄
--add-module 為添加的第三方模塊,此次添加了fdfs的nginx模塊
--with..._module 表示啟用的nginx模塊,如此處啟用了http_ssl_module模塊
根據需要來自行選擇,如下是我的執行腳本
./configure --prefix=/home/songxiaohu/nginx-1.16.0/nginx ? --with-http_stub_status_module --with-http_ssl_module
3、
可能出現的錯誤:
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?出現./configure: error: C compiler cc is not found
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?解決辦法:yum -y install gcc gcc-c++ autoconf automake make
出現:./configure: ?error:?the?HTTP?rewrite?module?requires?the?PCRE?library.
解決方法:yum?-y?install?pcre-devel
出現:SSL modules require the OpenSSL library
解決方法:yum?install?openssl-devel?
4、執行
? ? ? ? ?./configure --prefix=/home/songxiaohu/nginx-1.16.0/nginx ? --with-http_stub_status_module --with-http_ssl_module
5、編譯
? ? ? ?執行make?進行編譯,如果編譯成功的話會在第一步中objs中出現一個nginx文件
6、安裝
執行make install 進行安裝,安裝后--prefix 中指定的安裝目錄下(此處為:/home/songxiaohu/nginx-1.16.0/nginx)存在相關的文件
7、啟動nginx
nginx的一些常用管理命令
? ? ? ? ? ? ? ? ? ? ?啟動:nginx –c ../conf/nginx.conf
重啟:nginx -s reload
停止:nginx -s stop或者是通過kill nginx進程號
查看版本:nginx –V
?