0
我有一个wordpress安装在/ var/www/blog中。我想通过www.domain.com来访问它,所以我创建包含domain.com Nginx的配置文件:nginx配置为wordpress
server {
listen 80;
server_name domain.com www.domain.com;
root /var/www/blog;
index index.php index.html index.htm;
access_log /var/log/nginx/www.domain.com.access.log;
error_log /var/log/nginx/www.domain.com.error.log;
location/{
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
但是当我打开www.domain.com时,CSS/JS文件不加载。在我的error.log我得到:
2013/12/15 12:47:29 [error] 19562#0: *9 open() "/var/www/blog/blog/wp-content/themes/twentytwelve/style.css" failed (2: No such file or directory), client: yy.yy.yy.yy, server: domain.com, request: "GET /blog/wp-content/themes/twentytwelve/style.css?ver=3.8 HTTP/1.1", host: "xx.xx.xx.xx", referrer: "http://xx.xx.xx.xx/"
2013/12/15 12:47:29 [error] 19562#0: *11 open() "/var/www/blog/blog/wp-content/themes/twentytwelve/js/navigation.js" failed (2: No such file or directory), client: yy.yy.yy.yy, server: domain.com, request: "GET /blog/wp-content/themes/twentytwelve/js/navigation.js?ver=1.0 HTTP/1.1", host: "xx.xx.xx.xx", referrer: "http://xx.xx.xx.xx/"
我不明白为什么“/ blog /”被添加到链接中。 感谢您的帮助!
我想你的配置,但我得到了'2013年12月15日十三时34分57秒[错误] 21982#0:* 39或改写内部重定向周期,同时在内部重定向到“/index.php/blog/wp-content/themes/twentytwelve/style.css”,客户端:yy.yy.yy.yy,服务器:domain.com,请求:“GET /博客/wp-content/themes/twentytwelve/style.css?ver=3.8 HTTP/1.1“,主机:”xx.xx.xx.xx“,引荐来源:”http://www.domain.com/“'。所以我在/index.php和$ request_uri之间加了一个空格。现在css/js已经成功加载,但wordpress的显示仍然没有显示,当我点击一个链接时,页面被下载。 – kdelemme
为什么它试图通过index.php访问CSS?不应该是'/ blog/wp-content/themes/twentytwelve/style.css'没有'index.php' –
是的,它应该但我不知道为什么。 – kdelemme