nginx默認配置和默認站點啟動


1.nginx的配置文件nginx.conf

cd /etc/nginx/

vim nginx.conf

打開后的文件為:

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;//所有nginx 的content-type的配置
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 /var/log/nginx/access.log main;//定義訪問的日志

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;//客戶端和服務端超時的時間

#gzip on;

include /etc/nginx/conf.d/*.conf;//子配置文件
}

2.nginx.conf的子配置文件(/etc/nginx/conf.d/*.conf)

cd /etc/nginx/conf.d/

ls

vim default.conf

打開的文件為

server {
listen 80;//server所監聽的端口
server_name localhost;//server的服務名,服務用域名方式訪問的域名的地址

#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;

location / {//一個server可以有多個location,location /代表一個server當沒有其他的路徑的時候默認采用/,訪問所有的首頁路徑或自路徑都進入到這個location中進行訪問
root /usr/share/nginx/html;//location里面所返回的頁面的路徑
index index.html index.htm;//定義首頁默認訪問哪個頁面
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 404 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
"default.conf" 45L, 1096C


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM