Get [Wordpress|http://wordpress.org/] running on Apache 2.4 using PHP-FPM.

I am running multiple wordpress sites on a single web server, but want to keep them as isolated as possible.

This config emulates the .htaccess setup traditionally found in wordpress sites, but is a lot faster

## No longer needed
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^ /index.php [L]

Here is the VirtualHost setup:

<VirtualHost *:80>
 ServerName blog1.example.com
 ServerAlias *.blog1.example.com
 DocumentRoot "/var/www/html/blog1.example.com"
 <Directory "/var/www/html/blog1.example.com">
  Require all granted
  DirectoryIndex index.php
  AllowOverride FileInfo
  FallbackResource /index.php
 </Directory>
 <Directory "/var/www/html/blog1.example.com/wp-admin">
  FallbackResource disabled
 </Directory>
 ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9001/var/www/html/blog1.example.com/$1
</VirtualHost>

<VirtualHost *:80>
 ServerName blog2.example.com
 ServerAlias *.blog2.example.com
 DocumentRoot "/var/www/html/blog2.example.com"
 <Directory "/var/www/html/blog2.example.com">
  Require all granted
  DirectoryIndex index.php
  AllowOverride FileInfo
  FallbackResource /index.php
 </Directory>
 <Directory "/var/www/html/blog2.example.com/wp-admin">
  FallbackResource disabled
 </Directory>
 ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9002/var/www/html/blog2.example.com/$1
</VirtualHost>

My php-fpm setup (should be improved to include chroot) is pretty stock from php.net

Note these are not complete files, but just the main snippets to show what was done

#/etc/php-fpm.conf
include=/etc/php-fpm.d/*.conf
#/etc/php-fpm.d/blog1.conf
[wp_blog1]
listen = 127.0.0.1:9001
listen.allowed_clients = 127.0.0.1
user = wp_blog1
group = apache
...
#/etc/php-fpm.d/blog2.conf
[wp_blog2]
listen = 127.0.0.1:9002
listen.allowed_clients = 127.0.0.1
user = wp_blog2
group = apache
...

Then on my web servers:

useradd -d /var/www/html -s /sbin/nologin -g apache wp_blog1
useradd -d /var/www/html -s /sbin/nologin -g apache wp_blog2
  • No labels