一年多后,我回来回答我自己的问题,我不知道我应该感到骄傲还是尴尬。因此,我今天终于找到了一些时间来解决这个问题,并设法使这个配置正常工作。原来在我的原始配置中缺少了一些语句,但关键的更改是在wp config中。php。要将所有内容整合在一起,请从我的nginx配置开始(它几乎完全从nginx wiki中删除):
server {
listen XXX.XXX.XXX.XXX:80;
server_name wptest.mydomain.com;
error_log /var/log/nginx/wp-error.log;
## Your only path reference.
root /var/www/wordpress;
## This should be in your http block and if it is, it\'s not needed here.
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn\'t break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \\.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:80;
}
location ~* \\.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
接下来,我的Apache配置:
<VirtualHost 127.0.0.1>
server_name wptest.mydomain.com
ServerAdmin [email protected]
LogLevel warn
ErrorLog /var/log/apache2/wp-error.log
CustomLog /var/log/apache2/wp-access.log combined
AddType application/x-httpd-fastphp .php
AddHandler php-fastcgi .php
Action php-fastcgi /fastcgi
Alias /fastcgi /var/www/wordpress
FastCgiExternalServer /var/www/wordpress -host 127.0.0.1:9000
DocumentRoot /var/www/wordpress
#Site Directives
RewriteEngine on
Options +FollowSymLinks +ExecCGI -Indexes -MultiViews
<Directory />
AllowOverride None
</Directory>
<Directory /var/www/wordpress/>
AllowOverride Limit FileInfo AuthConfig
order allow,deny
allow from all
</Directory>
</VirtualHost>
最后,wp配置中的一个额外行。php文件,使其能够正常工作(摘自
Codex)
$_SERVER[\'HTTP_HOST\'] = $_SERVER[\'HTTP_X_FORWARDED_HOST\'];
通过这种配置,我已经测试了相当长的permalinks via。htaccess工作正常。