#進程守護者:
user nginx;
#錯誤日志
error_log logs/error.log;
#pid進程信息:
pid logs/nginx.pid;
#worker進程數(shù):
worker_processes 1;
#每進程處理連接數(shù):
worker_connections 1024;
#主配置區(qū)域結構:
http{
#mime文件類型
include mime.types;
#默認為附件類型
default_type application/octet-stream;
#訪問日志格式
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#開啟訪問日志
#access_log logs/access.log main;
#延遲發(fā)送途戒,優(yōu)化帶寬阻塞
sendfile on;
#tcp_nopush on;
#等待超時時間
#keepalive_timeout 0;
keepalive_timeout 65;
#網(wǎng)頁壓縮傳輸
gzip on;
#第一臺http虛擬主機配置
server{
#端口號
listen 80;
#網(wǎng)站域名
server_name localhost;
#web字符集
#charset koi8-r;
#訪問日志
#access_log logs/host.access.log main;
#匹配192.168.2.1或192.168.2.1/
location / {
#設置網(wǎng)站根目錄
root html;
#設置默認首頁
index index.php index.html index.htm;
}
#設置404錯誤頁面
#error_page 404 /404.html;
#設置50x錯誤頁面
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#訪問php文件時直接交給本機apache服務來處理
location ~ \.php$ {
proxy_pass http://127.0.0.1;
}
#請求php文件時交給php-fpm處理
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
拒絕所有人訪問.htaccess文件
location ~ /\.ht {
deny all;
}
}
#第二臺http虛擬主機配置
server {
listen 8000;
listen somename:8080;
server_name somename alias another.alias;
location / {
root html;
index index.html index.htm;
}
}
#配置https虛擬主機
server {
listen 443 ssl;
server_name localhost;
ssl_certificate cert.pem;
ssl_certificate_key cert.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}
}
Nginx常用配置
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門肺孵,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人颜阐,你說我怎么就攤上這事平窘。” “怎么了凳怨?”我有些...
- 文/不壞的土叔 我叫張陵瑰艘,是天一觀的道長。 經(jīng)常有香客問我肤舞,道長紫新,這世上最難降的妖魔是什么? 我笑而不...
- 正文 為了忘掉前任李剖,我火速辦了婚禮芒率,結果婚禮上,老公的妹妹穿的比我還像新娘篙顺。我一直安慰自己偶芍,他們只是感情好,可當我...
- 文/花漫 我一把揭開白布德玫。 她就那樣靜靜地躺著匪蟀,像睡著了一般。 火紅的嫁衣襯著肌膚如雪化焕。 梳的紋絲不亂的頭發(fā)上萄窜,一...
- 文/蒼蘭香墨 我猛地睜開眼谜疤,長吁一口氣:“原來是場噩夢啊……” “哼佃延!你這毒婦竟也來了?” 一聲冷哼從身側響起夷磕,我...
- 正文 年R本政府宣布蕴潦,位于F島的核電站,受9級特大地震影響嘿期,放射性物質(zhì)發(fā)生泄漏品擎。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一备徐、第九天 我趴在偏房一處隱蔽的房頂上張望萄传。 院中可真熱鬧,春花似錦蜜猾、人聲如沸秀菱。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽衍菱。三九已至,卻和暖如春肩豁,著一層夾襖步出監(jiān)牢的瞬間脊串,已是汗流浹背。 一陣腳步聲響...