nginx安裝步驟 nginx安裝及配置教程

各位老鐵們,大家好,今天由我來為大家分享nginx安裝步驟,以及nginx安裝及配置教程的相關問題知識,希望對大家有所幫助。如果可以幫助到大家,還望關注收藏下本站,您的...
各位老鐵們,大家好,今天由我來為大家分享nginx安裝步驟,以及nginx安裝及配置教程的相關問題知識,希望對大家有所幫助。如果可以幫助到大家,還望關注收藏下本站,您的支持是我們最大的動力,謝謝大家了哈,下面我們開始吧!
如何快速安裝Nginx
下面介紹一下Centos下安裝Nginx的方法
Nginx的官網:http://nginx.org/,Nginx有三個版本:穩定版、開發版和歷史穩定版。開發版更新快,包含最新的功能和bug修復,但同時也可能會出現新的bug。開發版一旦更新穩定下來,就會被加入穩定版分支,穩定版更新較慢,但bug較少,所以生產環境優先選擇穩定版。
一、下載Nginx安裝文件目前最新穩定版:
http://nginx.org/download/nginx-1.16.0.tar.gz
,可以先下載好安裝文件再通過ftp上傳的CentOS上,也可以在CentOS上直接通過wget命令下載,這里我將文件下載到了/home/software文件夾下,如下:[root@localhostsoftware]#pwd/home/software[root@localhostsoftware]#wgethttp://nginx.org/download/nginx-1.10.1.tar.gz二、解壓安裝文件[root@songguoliangsoftware]#tar-xzvfnginx-1.10.1.tar.gz三、執行configure命令通過cd命令進入Nginx解壓文件目錄,執行該目錄下的configure命令,--prefix是打算將Nginx安裝在哪個目錄。在執行configure命令之前,確保安裝了gcc、openssl-devel、pcre-devel和zlib-devel軟件庫(gzip模塊需要zlib庫,rewrite模塊需要pcre庫,ssl功能需要openssl庫),也可以直接執行configure命令,根據提示缺少的軟件庫安裝,下面有缺少相應庫報的錯誤信息和安裝依賴庫的方法。
為了方便,我們可以先安裝一下必須的軟件庫。
[root@localhostsoftware]#yum-yinstallgccpcre-develzlib-developenssl-devel出現類似下圖信息或提示之前已經安裝過等信息,說明已經安裝好依賴庫。如下:
這樣事先安裝好依賴庫后,就不必看下面幾個處理錯誤的步驟了,直接進行configure,如下:
[root@localhostsoftware]#cdnginx-1.10.1[root@localhostnginx-1.10.1]#pwd/home/software/nginx-1.10.1[root@localhostnginx-1.10.1]#./configure--prefix=/usr/local/nginx1、如果報下面錯誤,說明還沒有安裝gcc編譯環境,可以通過yum在線安裝功能安裝gcc,重新執行configure命令。
[root@localhostnginx-1.10.1]#./configure--prefix=/usr/local/nginxcheckingforOS+Linux2.6.32-431.el6.x86_64x86_64checkingforCcompiler...notfound./configure:error:Ccompilerccisnotfound在線安裝gcc:
[root@localhostnginx-1.10.1]#yuminstallgcc2、如果報下面的錯誤,說明沒有安裝pcre-devel庫,通過yum在線安裝pcre后,重新執行configure命令。
./configure:error:theHTTPrewritemodulerequiresthePCRElibrary.Youcaneitherdisablethemodulebyusing--without-http_rewrite_moduleoption,orinstallthePCRElibraryintothesystem,orbuildthePCRElibrarystaticallyfromthesourcewithnginxbyusing--with-pcre=<path>option.在線安裝pcre-devel庫:
[root@localhostnginx-1.10.1]#yum-yinstallpcre-devel-y參數表示使用yum在線安裝時,如果需要用戶輸入Y/N時自動輸入Y。
3、如果報下面的錯誤,說明沒有安裝zlib庫,安裝zlib庫后重新執行configure命令。
./configure:error:theHTTPgzipmodulerequiresthezliblibrary.Youcaneitherdisablethemodulebyusing--without-http_gzip_moduleoption,orinstallthezliblibraryintothesystem,orbuildthezliblibrarystaticallyfromthesourcewithnginxbyusing--with-zlib=<path>option.在線安裝zlib庫:
[root@localhostnginx-1.10.1]#yum-yinstallzlib-devel4、如果報以下錯誤,說明沒有安裝OpenSSL庫,安裝OpenSSL庫后重新執行configure命令。
./configure:error:SSLmodulesrequiretheOpenSSLlibrary.Youcaneitherdonotenablethemodules,orinstalltheOpenSSLlibraryintothesystem,orbuildtheOpenSSLlibrarystaticallyfromthesourcewithnginxbyusing--with-openssl=<path>option.在線安裝openssl庫:
[root@localhostnginx-1.10.1]#yuminstallopenssl-devel執行configure命令成功后,顯示如下信息:
checkingforzliblibrary...foundcreatingobjs/MakefileConfigurationsummary+usingsystemPCRElibrary+OpenSSLlibraryisnotused+usingbuiltinmd5code+sha1libraryisnotfound+usingsystemzliblibrarynginxpathprefix:"/usr/local/nginx"nginxbinaryfile:"/usr/local/nginx/sbin/nginx"nginxmodulespath:"/usr/local/nginx/modules"nginxconfigurationprefix:"/usr/local/nginx/conf"nginxconfigurationfile:"/usr/local/nginx/conf/nginx.conf"nginxpidfile:"/usr/local/nginx/logs/nginx.pid"nginxerrorlogfile:"/usr/local/nginx/logs/error.log"nginxhttpaccesslogfile:"/usr/local/nginx/logs/access.log"nginxhttpclientrequestbodytemporaryfiles:"client_body_temp"nginxhttpproxytemporaryfiles:"proxy_temp"nginxhttpfastcgitemporaryfiles:"fastcgi_temp"nginxhttpuwsgitemporaryfiles:"uwsgi_temp"nginxhttpscgitemporaryfiles:"scgi_temp"四、執行make命令[root@localhostnginx-1.10.1]#make五、執行makeinstall命令[root@localhostnginx-1.10.1]#makeinstall步驟四和步驟五可以合并執行如下命令,連接符&&代表前面一個命令如果執行成功則繼續執行后面的命令,如果前面命令執行失敗則不再執行后面的命令。而||表示如果前面的命令執行成功則不執行后面的命令,如果前面的命令執行失敗則繼續執行后面的命令
[root@localhostnginx-1.10.1]#make&&makeinstall六、啟動Nginx服務[root@localhostnginx-1.10.1]#cd/usr/local/nginx/[root@localhostnginx]#ll總用量16drwxr-xr-x.2rootroot409610月123:35confdrwxr-xr-x.2rootroot409610月123:35htmldrwxr-xr-x.2rootroot409610月123:35logsdrwxr-xr-x.2rootroot409610月123:35sbin[root@songguoliangnginx]#./sbin/nginx通過瀏覽器訪問Nginx,顯示如下welcometonginx!頁面便表示安裝成功:
nginx啟動、重啟、重新加載配置文件和平滑升級nginx啟動、重啟、重新加載配置文件和平滑升級可以參考我博客
https://blog.csdn.net/gnail_oug/article/details/52754491
以上回答希望能對你有幫助
安裝nginx怎么看是否支持https
環境都支持HTTPS的,只是沒有SSL,需要淘寶Gworg獲取SSL證書才可以。
推薦環境如下:WIN2008R2IIS7以上版本CentOS6+OpenSSL1.0.1c+Apache2.4+Nginx1.0.6+JDK1.7tomcat7.0.56+CentOS8如何安裝Nginx
方式一:yum安裝
安裝:
yuminstallnginx
啟用并啟動Nginx服務:
sudosystemctlenablenginx
sudosystemctlstartnginx
sudosystemctlstopnginx
要驗證服務是否正在運行,檢查其狀態:
sudosystemctlstatusnginx
方式二:自定義目錄安裝
1.安裝工具和庫
yum-yinstallgcc-c++pcrepcre-develzlibzlib-developensslopenssl-devel
#PCRE是一個Perl庫,包括perl兼容的正則表達式庫。nginx的http模塊使用pcre來解析正則表達式
#zlib庫提供了很多種壓縮和解壓縮的方式,nginx使用zlib對http包的內容進行gzip
2.下載并解壓nginx
wget-chttps://nginx.org/download/nginx-1.18.0.tar.gz
tar-zxvfnginx-1.18.0.tar.gz
1.configure
1
./configure--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_module--with-http_v2_module--with-http_sub_module--with-http_gzip_static_module--with-pcre
#--prefix指定安裝路徑
#--with-http_stub_status_module允許查看nginx狀態的模塊
#--with-http_ssl_module支持https的模塊
執行成功后顯示的文件路徑:
Configurationsummary+usingsystemPCRElibrary+usingsystemOpenSSLlibrary+usingsystemzliblibrary
nginxpathprefix:"/usr/local/nginx"nginxbinaryfile:"/usr/local/nginx/sbin/nginx"nginxmodulespath:"/usr/local/nginx/modules"nginxconfigurationprefix:"/usr/local/nginx/conf"nginxconfigurationfile:"/usr/local/nginx/conf/nginx.conf"nginxpidfile:"/usr/local/nginx/logs/nginx.pid"nginxerrorlogfile:"/usr/local/nginx/logs/error.log"nginxhttpaccesslogfile:"/usr/local/nginx/logs/access.log"nginxhttpclientrequestbodytemporaryfiles:"client_body_temp"nginxhttpproxytemporaryfiles:"proxy_temp"nginxhttpfastcgitemporaryfiles:"fastcgi_temp"nginxhttpuwsgitemporaryfiles:"uwsgi_temp"nginxhttpscgitemporaryfiles:"scgi_temp"
2.編譯并安裝
make&&makeinstall
進入到安裝nginx目錄下面的sbin啟動命令./nginx
打開瀏覽器訪問你的IP地址,顯示此頁面說明nginx啟動成功。
其他命令:
./nginx-squit:(溫和)此方式停止步驟是待nginx進程處理任務完畢進行停止。./nginx-sstop:(強硬)此方式相當于先查出nginx進程id再使用kill命令強制殺掉進程。./nginx-sreload重啟nginx(不推薦此方法,推薦先停止在啟動)
好了,關于nginx安裝步驟和nginx安裝及配置教程的問題到這里結束啦,希望可以解決您的問題哈!
本文鏈接:http://xinin56.com/qianduan/3133.html