Nginx網站服務

相對於Apache體積小,性能高,支持併發30000~50000
編譯安裝(光盤共享)
yum -y install pcre-devel zlib-devel #前提條件
tar zxvf /abc/nginx-1.12.0.tar.gz -C /usr/src/
cd /usr/src/nginx-1.12.0/
useradd -M -s /sbin/nologin nginx #建立服務用戶nginx
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module 統計模塊
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin
nginx -t #檢測服務
nginx #啓動服務
netstat -anpt | grep nginx
終端瀏覽器
yum -y install elinks
elinks http://localhost
主配置文件
vim /usr/local/nginx/conf/nginx.conf
全局配置php

處理進程數html

服務配置
servser {
listen 80; #表明監聽的端口號 ip + 端口號
server_name www.baidu.com; #網站的域名
charset utf-8; #支持的字符集
location / { #根目錄配置模塊
root /var/www/html/; #網站根目錄位置
index index.html index.php index.htm; #識別默認頁
}
error_page 500 502 503 504 /50x.html; #錯誤反饋頁面
location = /50x.html { #錯誤頁面配置
root /var/www/html;
}
location /status { #配置統計模塊
stub_status on; #開啓統計功能
access_log off; #關閉日誌功能
}nginx

}
關閉nginx
killall -3 nginx 或 killall -QUIT nginx
訪問統計頁面
http://127.0.0.1/status
Active connections: 2 #活躍鏈接數
server accepts handled requests
2 2 5 #TCP鏈接數 #成功握手數 #總處理數
Reading: 0 Writing: 1 Waiting: 1
虛擬主機
主配置文件添加server{}
建立每一個網站所對應的網頁
修改vim /etc/hosts文件
127.0.0.1 www.benet.com
127.0.0.1 www.accp.com
重啓nginx服務vim

相關文章
相關標籤/搜索