1.將nginx的壓縮包nginx-1.8.0.tar.gz上傳到linux服務器
2.由于nginx是c語言開發的并且我們這里是通過編譯nginx的源碼來安裝nginx,所以linux上要安裝c語言的編譯環境gcc,
如果已經安裝此步可以省略,否則執行命令:
yum?install?gcc-c++
3.nginx的http模塊使用pcre來解析正則表達式,所以需要在linux上安裝pcre庫。
yum?install?-y?pcre?pcre-devel
4.zlib庫提供了很多種壓縮和解壓縮的方式,nginx使用zlib對http包的內容進行gzip,所以需要在linux上安裝zlib庫。
yum?install?-y?zlib?zlib-devel
5.nginx不僅支持http協議,還支持https(即在ssl協議上傳輸http),所以需要在linux安裝openssl庫。
yum?install?-y?openssl?openssl-devel
6.在linux上創建nginx的臨時目錄,注意我這里是在linux文件系統下的 /var下創建文件夾temp在temp下創建nginx。即:/var/temp/nginx
7.執行命令:
./configure? --prefix=/usr/local/nginx? --pid-path=/var/run/nginx/nginx.pid? --lock-path=/var/lock/nginx.lock? --error-log-path=/var/log/nginx/error.log? --http-log-path=/var/log/nginx/access.log? --with-http_gzip_static_module? --http-client-body-temp-path=/var/temp/nginx/client? --http-proxy-temp-path=/var/temp/nginx/proxy? --http-fastcgi-temp-path=/var/temp/nginx/fastcgi? --http-uwsgi-temp-path=/var/temp/nginx/uwsgi? --http-scgi-temp-path=/var/temp/nginx/scgi
8.編譯源碼,安裝nginx:
make make?install
9.啟動nginx:
cd?/usr/local/nginx/sbin/ ./nginx?-c?/usr/local/nginx/conf/nginx.cof
在瀏覽器中訪問: http://localhost
我們此時也可以查看到nginx進程的運行情況:
ps?aux|grep?nginx
10.nginx服務器的停止方式:
方式一:先查出nginx進程id再使用kill命令強制殺掉進程。
cd?/usr/local/nginx/sbin ./nginx?-s?stop
方式二(推薦):待nginx進程處理任務完畢進行停止。
cd?/usr/local/nginx/sbin ./nginx?-s?quit
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END