Nginx使用、安裝、啟動、常用命令
阿新 • • 發佈:2018-12-04
【輕量級】 Nginx 的web伺服器
測試伺服器阿里雲 香港 可用區C
47.89.12.182
1 vCPU 2 GB (I/O優化)
ecs.n4.small 1Mbps
輕量級 149.129.101.114
安裝流程
下載地址
下載好後存到單獨的目錄
mv nginx-1.15.7 /usr/local/nginx
把下載檔案下載到src中並解壓
wget http:網址 -P /usr/src
連線下載
-
mac終端連結伺服器並下載
ssh -l root IP
如果ssh連不了,清空下ip
vi ~/.ssh/known_hosts
常用命令:hostname
檢視伺服器名ifconfig
檢視伺服器ipwget http:網址 -P /usr/src
下載網路資源,這裡放到/usr/srcyum -y install 命令名
新增下載命令du -h 檔名
檢視檔案具體資訊/sbin/nginx -g ../conf/nginx.conf
檢查修改conf是否正確killall -s HUP nginx
立即重新載入配置檔案
安裝的前戲
-
tar xf 檔名
解壓壓縮包 -
cd進目錄解壓好的目錄中
-
yum -y install gcc pcre-devel zlib zlib-devel
-
指定軟體安裝路徑
./configure --prefix=/usr/local/nginx
如果出現error 就必須要解決否則後面無辜出錯
編譯
make
使用gcc將原始碼生成可執行程式
如果出現error 就必須要解決否則後面無辜出錯
安裝
make install
目錄歸類
安裝目錄
:nginx path prefix: “/usr/local/nginx”啟動檔案
:nginx binary file: “/usr/local/nginx/sbin/nginx”模組
配置檔案目錄
:nginx configuration prefix: “/usr/local/nginx/conf”pid程序記錄檔案
:nginx configuration file: “/usr/local/nginx/conf/nginx.conf” nginx pid file: “/usr/local/nginx/logs/nginx.pid”錯誤日誌
:nginx error log file: “/usr/local/nginx/logs/error.log”訪問日誌
:nginx http access log file: “/usr/local/nginx/logs/access.log”
啟動
-
驗證埠是否佔用
lsof -i :80
或檢視端口占用netstat -ntpl
-
啟動
/usr/local/nginx/sbin/nginx
指定路徑啟動 -
驗證是否啟動:直接訪問網址
或者用elinks 文字瀏覽器(不會有快取更真實)
沒有的話就安裝yum -y install elinks
訪問:elinks http://ip --dump