您的位置:首页 > 运维架构 > Nginx

nginx.conf简单配置

2015-10-22 08:59 585 查看
前言:

最简单的nginx.conf配置文件,纯干货,不解释!
主配置文件

[root@lnmp 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;
}
扩展配置文件

[root@lnmp 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/ 本文出自 “挨刀客” 博客,请务必保留此出处http://chboy.blog.51cto.com/9959876/1705083
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: