nginx配置文件
###核心模块(进程数等)user nginx; #启动用户worker_processes auto; #开启nginx数量error_log /var/log/nginx/error.log notice; #错误日志pid /var/run/nginx.pid; #进程号####事件驱动模块(工作模式等)events { worker_connections 1024; #工作连接数,默认1个程序可以为10000个人服务}###http内核模块(文档程序)http { include /etc/nginx/mime.types; #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"';#访问日志,main格式 access_log /var/log/nginx/access.log main; sendfile on; #加速nginx访问 #tcp_nopush on; #优化nginx访问 keepalive_timeout 65; #长连接 #gzip on; #压缩 include /etc/nginx/conf.d/*.conf; #导入子配置文件}
默认网站:/etc/nginx/conf.d/default.conf
###server默认会在http里面server { listen 80; #监听端口 server_name localhost; #域名,服务器购买的域名 #access_log /var/log/nginx/host.access.log main; #访问日志路径 location / { #网址的位置 root /usr/share/nginx/html; #网站放那个目录 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 /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; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #}}