nginx新增vhost网站配置

log_format dl.kaifazhe.me ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” $http_x_forwarded_for’;
server
{
listen 80;
#域名
server_name dl.kaifazhe.me;
index index.html index.htm index.php default.html default.htm default.php;
# 网站目录
root /home/vhost/dl.kaifazhe.me;

#修改添加的
error_page 404 /404.htm;
error_page 500 502 503 504 /50x.htm;

location / {
expires 60s;
expires_by_types 24h text/css;
concat on;
# 允许concat最大的文件数 默认最大设置十个文件。
# (默认: 10)
concat_max_files 10;
# 只允许相同类型的文件
concat_unique on;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}

#修改添加的
location ~ .*\.(php|php5)?$
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}
#日志目录
access_log /home/wwwlogs/dl.kaifazhe.me.log dl.kaifazhe.me;
}

友荐云推荐

关于开发者

开发者一枚...
此条目发表在linux, Nginx, 服务器分类目录,贴了, , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注