Background:
I have had some difficulty trying to install WordPress? MU for a client (a major university). In this case, PHP is available as CGI, rather than as an Apache Module. The _SERVER["SCRIPT_FILENAME"] variable is reported as /cgi-php5/php.
I managed to resolve the issues through use of a workaround - which I detail below. In this case
Affected functions:
Initial installation and usage.
Steps to replicate:
- Install Apache.
- Install PHP as CGI, within a subdirectory of the cgi-bin.
- Attempt to install WordPress? MU.
Analysis:
The "regular" installation instructions will not install WordPress MU.
The problematic _SERVER scoped variables are:
_SERVER["SCRIPT_FILENAME"] which is reported as /usr/local/opt/php/php-5.2.1/bin/php .
_SERVER["SCRIPT_NAME"] which is reported as /cgi-php5/php .
The misconfiguration in the generated configuration files includes:
- $base in generated wp-config.php incorrectly defined as 'cgi-php5'.
- RewriteBase? in generated .htaccess incorrectly defined as 'cgi-php5'.
- the following database values are set incorrectly:
tables for multi-user support:
| table name | column name | column value
|
| wp_blogs | path | /cgi-php5/
|
| wp_site | path | /cgi-php5/
|
the default blog:
Workaround 1 : Possible Manual Workaround
The first attempt was to see if a manual workaround is possible, after an incorrect installation:
- go through database and fix table values listed above manually.
- fix generated wp-config.php:
cp wp-config.php wp-config.php2
pico wp-config.php2
changing:
$base = '/cgi-php5/';
to:
$base = '/site/blogs/';
rm wp-config.php
(select override YES, must be in BASH shell to do this)
mv wp-config.php2 wp-config.php
chmod 644 wp-config.php
- fix .htaccess' by removing it:
rm .htaccess
and replacing with this new .htaccess:
RewriteEngine On
RewriteBase /site/blogs/
#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
- Fix ownership of .htaccess
chown www-process
chmod 600 .htaccess
Step-By-Step Workaround
Unsuccessful Installation Removal
WARNING: Before following these instructions, ensure any remnants of previous unsuccessful installations are removed:
Basic Installation
The first part of the instructions closely mirror the official installation instructions, albeit in more detail:
Patching the Install Files
- At this point, if you follow the regular installation routine for WordPress MU, you would proceed to visit http://yoursite.com/subsite/blogs/, which generates all of the required configuration files through a web interface. VERY IMPORTANT : don't follow this part of the instructions just yet. Instead, its necessary to patch some of the installer files to make the site work with the ucl.ac.uk hosting environment.
- at line 68, add the following:
// Fix for hosting that sets SCRIPT_FILENAME to something ending in /bin/php for all requests
if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'bin/php') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
- and at line 76:
if (strpos($_SERVER['SCRIPT_NAME'], 'cgi-php5') !== false)
unset($_SERVER['PATH_INFO']);
- then visit: http://yoursite.com/subsite/blogs/
- follow the on-screen instructions:
- select sub-directories for Blog Addresses type.
- add your database parameters, and site name, etc.