问题
I just moved a Wordpress multi-site from a Apache 2.4 Prefork + mod_php to a new server with Apache 2.4 Event + php-fpm.
The site is working well on the frontend and it is a lot faster then before due to the CGI, but... the Wordpress administration panel is working just for the main site (and network administration). The admin area for the second site is no more working, but the frontend is working great.
Examples
- http://www.example.com/en/wp-admin/ => works
- http://www.example.com/en/wp-admin/post-new.php => goes on error 404
I tried to debug the rewrites, but the unique log I have (also using Debug Level 8) is
[proxy_fcgi:error] [pid 13700:tid 140381047965440] [client X.X.X.X:54354] AH01071: Got error 'Primary script unknown\n', referer: http://www.example.com/en/wp-admin/
Follwing my configurations. Any help appreciated. Thank you.
Virtual Host
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot "/srv/www/example.com/public_html"
<IfModule mpm_event_module>
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/srv/www/example.com/public_html/$1
</IfModule>
<Directory "/srv/www/example.com/public_html">
AllowOverride all
Require all granted
</Directory>
ErrorLog /srv/www/example.com/logs/error_log
TransferLog /srv/www/example.com/logs/access_log
</VirtualHost>
.htaccess
<Files "xmlrpc.php">
Order Allow,Deny
Deny from all
</Files>
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(admin|content|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+]/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
回答1:
Not sure if you found the solution. Just like to share our solution to this issue.
We've just added the lines below to the apache config. This will do the forwarding to FPM for all items in the regex.
ProxyPassMatch ^/([_0-9a-zA-Z-]+/)?(wp-(admin|activate|blog-header|comments-post|config|cron|links-opml|load|login|mail|settings|signup|trackback)\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$2
回答2:
I add a different solution because @parpar's one, although it is working for me, it continues to throw proxy_fcgi
errors:
[proxy_fcgi:error] Got error 'Primary script unknown\n'
The solution consists in removing the ProxyPassMatch way to call PHP FPM and including a handler to manage PHP calls into the Directory
environment:
<Directory "/path/to/host/root">
# rest of configuration...
<FilesMatch \.php$>
SetHandler "proxy:unix:/path/to/socket.sock|fcgi://localhost"
</FilesMatch>
</Directory>
来源:https://stackoverflow.com/questions/34698636/apache-2-4-fpm-wordpress-multisite-url-rewrite-not-working-in-admin