Linux WEB服務器搭建-Nginx篇
阿新 • • 發佈:2018-01-14
輕量 模塊 open tel selinux 無法 app 處理 訪問 nginx使用的三個方面
1.輕量級的web服務器
2.反向代理或負載均衡
3.緩存服務器
nginx使用epoll模型,apache使用傳統的select模型,所以nginx在處理靜態小文件時能夠處理的並發數更多。 cd nginx-1.6.3
useradd nginx -s /sbin/nologin -M ----------->創建nginx服務用戶
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.3/ \
--with-http_stub_status_module --with-http_ssl_module
make&&make install /application/nginx/sbin/nginx -t
出現如下信息
1.輕量級的web服務器
2.反向代理或負載均衡
3.緩存服務器
nginx使用epoll模型,apache使用傳統的select模型,所以nginx在處理靜態小文件時能夠處理的並發數更多。
源代碼安裝。
檢查系統是否有安裝pcre(讓nginx支持http的rewrite模塊),pcre-devel openssl------》基礎依賴包
openssl-devel 使用https時用到
安裝過程
cd /tuwei/tools/
wget http://nginx.org/download/nginx-1.6.3.tar.gz------》下載nginx
tar xf nginx-1.6.3.tar.gz
useradd nginx -s /sbin/nologin -M ----------->創建nginx服務用戶
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.3/ \
--with-http_stub_status_module --with-http_ssl_module
make&&make install
安裝完後創建軟連接,方便後續使用
ln -s /application/nginx-1.6.3/ /application/nginx
啟動nginx服務前檢查語法,養成好習慣。
出現如下信息
[root@node04 html]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful
如果提示相關相關模塊不存在,將模塊路徑放到模塊配置文件中
cat /etc/ld.so.conf
執行ldconfig 使配置修改生效
啟動nginx服務
/application/nginx/sbin/nginx
檢查服務是否啟動
- ps -ef |grep nginx
2.netstat -tnlp|grep 80
3.wget 127.0.0.1
4.curl -I 127.0.0.1
檢查nginx啟動效果,瀏覽器訪問
如果無法訪問
1.關閉selinux
2.關閉防火墻,在生產環境中,如有外網IP,請允許80端口訪問
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
客戶端訪問網站異常排查的三部曲
1.客戶端 ping IP ------》物理線路- telnet IP 80 -------》服務端防火墻
3.服務端 wget IP或者curl -I IP ------》模擬用戶訪問,排除http服務自身問題,根據輸出再排除
4.服務端 查看服務錯誤日誌
403錯誤
1.沒有首頁文件
2.首頁文件權限不夠
kill HUPcat nginx.pid
相當於重啟nginx服務
- telnet IP 80 -------》服務端防火墻
創建簡單站點
自己創建index.html
放到/application/nginx/html目錄然後進行訪問,nginx默認站點文件為index.html。
Linux WEB服務器搭建-Nginx篇