我尝试使用Google"在子目录中托管wordpress"似乎是关于将Wordpress安装移动到子目录,同时仍然从/
提供它。我想在/blog/
提供服务。
我有一个运行Nginx的docker镜像,另一个通过php-fpm运行Wordpress。我将wp_options表中的siteurl
更新为http://example.com/blog,最后得到了索引页面,但所有相关资产都给出了403错误。我虽然可能与我的Nginx配置中的重写指令有关,所以我尝试删除rewrite ^/blog/(.*) /$1 break;
,但这导致/blog
返回404。
这是我的Nginx conf的相关部分:
location /blog/ {
resolver ${RESOLVER_IP};
set $wordpress_host "${WORDPRESS_SERVICE_HOST}";
rewrite ^/blog/(.*) /$1 break;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /srv$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $document_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /srv;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTP_X_REAL_IP $remote_addr;
fastcgi_param HTTP_X_FORWARDED_FOR $proxy_add_x_forwarded_for;
fastcgi_param HTTP_X_FORWARDED_HOST $http_host;
fastcgi_param HTTP_X_FORWARDED_PROTO $real_scheme;
fastcgi_param HTTP_HOST $http_host;
# requests gzipped content from php. gunzip is used for clients that
# can't accept gzip.
fastcgi_param HTTP_ACCEPT_ENCODING "gzip";
fastcgi_param HTTP_X_PREFERRED_TYPE $preferred_type;
fastcgi_read_timeout 60;
fastcgi_next_upstream error timeout http_500 http_503;
fastcgi_buffers 16 64k;
# specifies buffer used for HTTP headers, doesn't need to be large
fastcgi_buffer_size 2k;
fastcgi_temp_file_write_size 64k;
fastcgi_pass $wordpress_host:80;
fastcgi_index index.php;
#echo '';
add_header X-document_root $document_root;
add_header X-fastcgi_script_name $fastcgi_script_name;
add_header X-request_uri $request_uri;
add_header X-document_uri $document_uri;
}
答案 0 :(得分:2)
如果您在Web_Root下创建了一个名为
blog
的目录,并将整个Wordpress上传到此位置,并对您数据库中的wp_options
表进行一些细微更改;您可能根本不需要触摸任何配置文件。导航到http://domain.com/blog/将提供预期的相同输出...(这是Wordpress页面)。
答案 1 :(得分:1)
如果您完全上传Wordpress,它应该正常工作,并在您需要时更改 siteurl 和主页记录。