- 前言:
最简单的nginx.conf配置文件,纯干货,不解释!
- 主配置文件
[[email protected] application]# cat nginx/conf/nginx.conf worker_processes 1; error_log logs/error.log error; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; 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; server { listen 80; location /{ deny all; } include extra/www.conf; include extra/bbs.conf; include extra/blog.conf; }
- 扩展配置文件
[[email protected] application]# cat nginx/conf/extra/bbs.conf server { listen 80; server_name bbs.chborg.com; root html/bbs; index index.php index.html index.htm; location ~ .*\.(php|php5)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } }
- 相关命令
/application/nginx/sbin/nginx -t /application/nginx/sbin/nginx -s reload
- 优点
- 拒绝使用ip地址访问,防止域名恶意绑定。
- 将server标签与主配置文件分开,便于管理,减少额外运维成本。
- 修改错误日志级别,可减少日志文件大小。
- 也可将access_log放入每个标签里面,便于分开管理和分析。
- 参考资料
http://nginx.org/en/docs/
时间: 2024-10-12 15:10:30