(On Debian 5.0. May be slightly different on other distros)
Create files in /etc/skel/:
$ cd /etc/skel
$ mkdir -P etc/php5
$ cp /etc/php5/apache2/php.ini /etc/skel/etc/php5/php.ini
$ mkdir fcgi-bin
$ vi fcgi-bin/php5.fcgi
Paste the following:
#!/bin/bash
export PHPRC=$PWD/../etc/php5
umask 022
export SCRIPT_FILENAME=$PATH_TRANSLATED
exec /usr/bin/php-cgi
Then, in Virtualmin > System Settings > Server Templates > Default Settings > Apache website > Directives and settings:
ServerName ${DOM}
ServerAlias www.${DOM}
DocumentRoot ${HOME}/public_html
ErrorLog /var/log/virtualmin/${DOM}_error_log
CustomLog /var/log/virtualmin/${DOM}_access_log combined
DirectoryIndex index.html index.htm index.php index.php4 index.php5
Options -Indexes IncludesNOEXEC FollowSymLinks ExecCGI
allow from all
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper ${HOME}/fcgi-bin/php5.fcgi .php
AddHandler cgi-script cgi
Important notes:
ExecCGIis required! Otherwise, 403 Forbidden errors will occur.- The wrapper script and php files must not be group/world-writable!
- Look in
/var/log/apache2/suexec.logfor hints if you’re having trouble.
Hi!
Just wanted to let you know that: a) I think your wordpress ate a part of the apache config you have there (everything between greater-than and lesser-than tags) b) maybe you’d like to point out the (obvious) prerequisites of having to install libapache2-mod-fcgid and php5-cgi c) this isn’t working for me – i only get 404 everywhere i go. and my /var/log/apache2/error_log says: “script ‘/var/www/php.php’ not found or unable to stat”, but i have NO idea where the ‘/var/www’ is coming from.
Hi Moritz:
a. I didn’t include anything between <> tags.. that’s just the partial bit of the config file that’s visible from that section of Virtualmin. If you edit the config file manually, of course, you’ll have to find the right place to put it.
b and c. Yes — in fact, another prerequisite is to have installed the Virtualmin packages for Apache, or have a custom build that changes the docroot (Search the manual for “docroot”). The default version of suEXEC only executes things under /var/www for security purposes. Do you see anything in the suexec log file?
Hi David,
First of all, thanks so much. I’ve been trawling forums and decimating my server for the last two days trying to get this working. Even though Virtualmin claim to provide one-click fcgid enable-ment for the GPL suite now, it didn’t work for me (kept redirecting me to the cgi-bin folder instead of executing the files in public_html).
So yeah, I got a Joomla sandbox site working by enabling the one-click cgi-wrapper, then modifying the apache ${DOM}.conf file to use your settings.
However (there’s always a however, isn’t there?), when I tried creating a server template with exactly what you wrote above (i.e. not using the one-click cgi thing then modifying), it didn’t quite work. When I transfer the Joomla core files into public_html and attempt to load up the browser step-by-step installer, it gives me a 503 error (unlike before when the installer worked perfectly).
The error I got in the apache error.log is: [warn] mod_fcgid: can’t apply process slot for /home/domains/joomla/public_html/index.php
[EDIT:] Okay, I found the solution. Turns out the problem was with the write permissions of the /var/lib/apache2/fcgid/sock directory. I chmod’d it to 755 and the problem was fixed.
Also, I had to chmod a+x ${HOME}/fcgi-bin/php5.fcgi to get it working. Is that normal or a security problem?
Again, thanks so much for ending my 48 hours of serverlicious torment!
Francis