1.新建配置文件
nano /etc/nginx/sites-available/test.com
2.配置内容
该配置为配置支持test.com
访问日志为/var/log/nginx/test.com.access.log
错误日志为/var/log/nginx/test.com.error.log
网站主目录为/var/www/test(注意php解析部分也要修改)
如果不是部署wordpress,删除wordpress rewrite start 到 wordpress rewrite stop的内容。
server
{
server_name .test.com;
access_log
/var/log/nginx/test.com.access.log;
error_log /var/log/nginx/test.com.error.log;
root /var/www/test;
index index.php index.html index.htm;
#wordpress rewrite start
#
unless the request is for a valid file, send
to bootstrap
if (!-e $request_filename)
{
rewrite ^(.+)$
/index.php?q=$1 last;
}
catch all
error_page 404 /index.php;
#
#wordress rewrite stop
use fastcgi for all php files
location ~ .php$
{
fastcgi_pass
127.0.0.1:9000;
fastcgi_index
index.php;
fastcgi_param
SCRIPT_FILENAME /var/www/test$fastcgi_script_name;
include
fastcgi_params;
}
#jpg jpeg gif png css
ico js swf files expires 30 day.
location ~ .(jpg|jpeg|gif|png|css|ico|js|swf)$
{
access_log off;
expires 30d;
}
# deny access to apache .htaccess files
location ~ /.ht
{
deny all;
}
}
3.链接配置
cd /etc/nginx/sites-enabled
ln -s /etc/nginx/sites-available/test.com
4.应用配置
/etc/init.d/nginx restart
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。