Convert PHP sites to use mod_fcgid with suEXEC

Arrgh!! if you could see my head now. :slight_smile:

It was indeed that. I ran dos2unix on the php5.cgi, changed the permissions and bang, all good.

Thanks Eric for your patience on this, crazy newlines - I used windows to generate the php5.fcgi script and I used Notepad++ to do so and evidently neglected to select ā€˜Convert to UNIX formatā€™.

So solution found:

Dont use Windows!

Easy.

Cheers,

Paul

Correct me if Iā€™m wrong, but seeing as itā€™s even hard to find simplified docs on how to setup FastCGI + SuExec (as opposed to fcgid), can I ask if FastCGI has essentially the same setup as mod_fcgid (namely a fcgi script wrapper)?

Reason I ask is I had a lot of difficulty getting FastCGI tutorials I found online to actually work - so I thought maybe setting it up using the basic tutorials for mod_fcgid here, with the obvious FastCGI config replacements from other sitesā€¦?

EDIT: Since then, I have got fastcgi to work. The reason I wanted FastCGI and not fcgid, is because I needed output buffering turned off with the -flush option. Now it seems to work :wink:

Although I do have some questions about the PHPRC variable: 1)is it ā€˜usableā€™ in both FastCGI and Fcgid, and 2) does this get picked up internally somewhere, because when set it in the wrapper script in FastCGI, I donā€™t see the path appear anywhere when i run phpinfo(); under the appropriate vhost? Hereā€™s my example setting:

[code:1]PHPRC = /home/user1/conf
export PHPRC
PHP_CGI=/usr/bin/php-cgi
PHP_FCGI_CHILDREN=4
PHP_FCGI_MAX_REQUESTS=1000

no editing below

export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
exec $PHP_CGI[/code:1]

solved! Just added ExecCGI to this line in apache virtualhost directive:

Options -Indexes IncludesNOEXEC FollowSymLinks

became

Options -Indexes IncludesNOEXEC ExecCGI FollowSymLinks

I forgot to mention that you should install the custom version of apache provided by virtualmin after running the install.sh script.

Add these sources to /etc/apt/sources.list:

deb http://download.webmin.com/download/repository sarge contrib
deb http://software.virtualmin.com/gpl/debian/ virtualmin-etch main

then install custom apache (2.2.3-50vm). I disabled the other repositories and then installed apt-get install apache. But this should also work

apt-get install apache2-mpm-worker

It looks like youā€™re on the right track.

Which version of Debian are you using?

Debian 5 just began making suexec a bit simpler to work with ā€“ first, what does this output:

/usr/lib/apache2/suexec -V

And then, if youā€™re using Debian 5, rather than recompiling, suexec can be tweaked here:

/etc/apache2/suexec/www-data

Thanks for the prompt follow up andreychek. Running Debian 4.0

[code:1]> /usr/lib/apache2/suexec -V
-D AP_DOC_ROOT="/home"
-D AP_GID_MIN=100
-D AP_HTTPD_USER=ā€œwww-dataā€
-D AP_LOG_EXEC="/var/log/apache2/suexec.log"
-D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
-D AP_UID_MIN=100
-D AP_USERDIR_SUFFIX=ā€œpublic_htmlā€[/code:1]
So, apparently the doc root is not the problem then, blast. This doesnā€™t help me any. Glad I didnā€™t already try to recompile the code though.

Yeah, that all looks pretty good.

Did you say that the suexec module is definitely being loaded in Apache?

Also, are you seeing any messages in /var/log/apache2/suexec.log?
-Eric

Okā€¦ progressā€¦ maybe? I have to restart the apache server to kick in the changes. Itā€™s always the simple things in life.

I can toggle between a 403 error and it "working" of sorts (but not as a running process of the user):

403 error:

[code:1]ā€¦
<Directory /home/micahk/public_html>
Options -Indexes IncludesNOEXEC FollowSymLinks
allow from all
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /home/micahk/fcgi-bin/php5.fcgi .php
</Directory>
ā€¦[/code:1]

"working" but w/out using the UID of the domain admin

[code:1]ā€¦
<Directory /home/micahk/public_html>
Options -Indexes IncludesNOEXEC ExecCGI FollowSymLinks
allow from all
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /home/micahk/fcgi-bin/php5.fcgi .php
</Directory>
ā€¦[/code:1]

There has not been a single error in the suexec.log file at any point in this process.

Any easy command to see if suexec and fcgid are actually running? They are both marked as enabled.

Canā€™t seem to editā€¦

In my /var/log/apache2/error.log I noticed these, maybe the problem lies in here somewhere. I am calling it quits for tonight. Thanks all.

[code:1]ā€¦
[Thu May 28 00:20:49 2009] [notice] mod_fcgid: call /home/micahk/public_html/test.php with wrapper /home/micahk/fcgi-bin/php5.fcgi
[Thu May 28 00:20:49 2009] [notice] mod_fcgid: server /home/micahk/public_html/test.php(4928) started
[Thu May 28 00:23:04 2009] [notice] caught SIGTERM, shutting down
[Thu May 28 00:23:05 2009] [notice] mod_fcgid: process /home/micahk/public_html/test.php(4928) exit(shutting down), terminated by calling exit(), return code: 0
ā€¦[/code:1]

Check suexec.log. This looks like maybe you have incorrect permissions somewhere (too much, not too little). Be sure the files being run are owned by the user/group, and are not writable by group or world.

suexec.log is still completely empty. Not a single byte.

Permissions:
~/fcgi-bin - 0755
~/fcgi-bin/php5.fcgi - 0755
~/etc/php5 - 0755
~/etc/php5/php.ini - 0755
~/public_html/test.php - 0644

All files are owned by the domain admin user.

Like anything else in linux, it is probably something really simple I am just overlooking. Iā€™ll go through from beginning to end and double check everythingā€¦ maybe I missed something small.

Hmmā€¦ in looking over your working and non-working examples again, I started to wanderā€¦

Do you have SuexecUserGroup defined in the VirtualHost section?

For all my VirtualHost definitions, I have a line like:

[code:1]SuexecUserGroup "#500" "#600"[/code:1]

Where #500 is the uid, and #600 is the #gid, of the Virtual Server owner.
-Eric

Ok, so the permissions, all the files, etc were perfect as is. I had to do two things:

  1. add SuexecUserGroup "#1004" "#1004" (number will be different for each user and group) in the VirtualHost section. THANK YOU ERIC! I doubt I would have found that one for at least another week.

  2. I had to add "ExecCGI" to the line Options -Indexes IncludesNOEXEC FollowSymLinks, in the <Directory /home/micahk/public_html> part of the VirtualHost section.

Thank you again Eric and Joe, I really appreciate your patience with me. It really is an easy process once you know what you are doing and know what to look for.

Hi,

Iā€™m running into an ā€˜head bang against the wallā€™ problem with suEXEC. Iā€™ve followed the instructions laid out by the posts, and as far as I can see, everything should work okā€¦(but of course it isnā€™t!)

Folder/file structure:

/home/domain/etc/php5/php.ini (644) (Owner/Group: domain)
/home/domain/fcgi-bin/php5.cgi (644) (Owner/Group: domain)

php5.fcgi:
#!/bin/bash
PHPRC=$PWD/ā€¦/etc/php5
export PHPRC
umask 022
SCRIPT_FILENAME=$PATH_TRANSLATED
export SCRIPT_FILENAME
exec /usr/bin/php-cgi

httpd.conf:

SuexecUserGroup "#503" "#504"
ServerName domain
ServerAlias domain
ServerAlias domain
ServerAlias domain
ServerAlias domain
DocumentRoot /home/domain/public_html
ErrorLog /var/log/virtualmin/domain_error_log
CustomLog /var/log/virtualmin/domain_access_log combined
ScriptAlias /cgi-bin/ /home/domain/cgi-bin/
ScriptAlias /awstats /home/domain/cgi-bin
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/domain/public_html>
Options -Indexes IncludesNOEXEC FollowSymLinks ExecCGI
allow from all
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /home/domain/fcgi-bin/php5.fcgi .php
</Directory>
<Directory /home/domain/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =domain
RewriteRule ^(.) https://domain:20000/ [R]
RewriteCond %{HTTP_HOST} =domain
RewriteRule ^(.
) https://domain:10000/ [R]
Alias /dav /home/domain/public_html
Alias /pipermail /var/lib/mailman/archives/public
<Location /dav>
DAV On
AuthType Basic
AuthName domain
AuthUserFile /home/domain/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
</Location>
<Files awstats.pl>
AuthName "domain statistics"
AuthType Basic
AuthUserFile /home/domain/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/])(.) https://domain:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
RedirectMatch /mailman/([^/])(.) https://domain:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
RemoveHandler .php
IPCCommTimeout 31

This is a fresh install of Virtualmin GPL on a CentOS 5.2 box, installed using the install.sh script, and I definitely have the vm version of httpd installed.

However, I still get a 500 Internal Server Error when I access a PHP page, and the following error in apache error logs:

[Thu Feb 19 14:00:33 2009] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Thu Feb 19 14:00:33 2009] [error] [client 12.34.56.78] Premature end of script headers: index.php

Iā€™m tantalisingly close to it working, but am not sure where to go from here.

Thanks for any help,

Paul

Hi,

Iā€™m running into an ā€˜head bang against the wallā€™ problem with suEXEC. Iā€™ve followed the instructions laid out by the posts, and as far as I can see, everything should work okā€¦(but of course it isnā€™t!)

Folder/file structure:

/home/domain/etc/php5/php.ini (644) (Owner/Group: domain)
/home/domain/fcgi-bin/php5.cgi (644) (Owner/Group: domain)

php5.fcgi:
#!/bin/bash
PHPRC=$PWD/ā€¦/etc/php5
export PHPRC
umask 022
SCRIPT_FILENAME=$PATH_TRANSLATED
export SCRIPT_FILENAME
exec /usr/bin/php-cgi

httpd.conf:

SuexecUserGroup "#503" "#504"
ServerName domain
ServerAlias domain
ServerAlias domain
ServerAlias domain
ServerAlias domain
DocumentRoot /home/domain/public_html
ErrorLog /var/log/virtualmin/domain_error_log
CustomLog /var/log/virtualmin/domain_access_log combined
ScriptAlias /cgi-bin/ /home/domain/cgi-bin/
ScriptAlias /awstats /home/domain/cgi-bin
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/domain/public_html>
Options -Indexes IncludesNOEXEC FollowSymLinks ExecCGI
allow from all
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /home/domain/fcgi-bin/php5.fcgi .php
</Directory>
<Directory /home/domain/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =domain
RewriteRule ^(.) https://domain:20000/ [R]
RewriteCond %{HTTP_HOST} =domain
RewriteRule ^(.
) https://domain:10000/ [R]
Alias /dav /home/domain/public_html
Alias /pipermail /var/lib/mailman/archives/public
<Location /dav>
DAV On
AuthType Basic
AuthName domain
AuthUserFile /home/domain/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
</Location>
<Files awstats.pl>
AuthName "domain statistics"
AuthType Basic
AuthUserFile /home/domain/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/])(.) https://domain:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
RedirectMatch /mailman/([^/])(.) https://domain:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
RemoveHandler .php
IPCCommTimeout 31

This is a fresh install of Virtualmin GPL on a CentOS 5.2 box, installed using the install.sh script, and I definitely have the vm version of httpd installed.

However, I still get a 500 Internal Server Error when I access a PHP page, and the following error in apache error logs:

[Thu Feb 19 14:00:33 2009] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Thu Feb 19 14:00:33 2009] [error] [client 12.34.56.78] Premature end of script headers: index.php

Iā€™m tantalisingly close to it working, but am not sure where to go from here.

Thanks for any help,

Paul

I created a wrapper ~/fcgi-bin/php5.fcgi. It is owned by the user and is executable and not writable by g/o. I copied php.ini from /etc/php5/apache2 to ~/user/etc/php5. I added 2 lines to the apache directives under the public_html section.

My php scripts still donā€™t work. I get 403 errors on them, although they have the correct user and group and have exec permissions. Any suggestions?

This is my virtual host file:

<VirtualHost 111.111.246.121:80>
SuexecUserGroup "#1001" "#1002"
ServerName robertgrab.com
ServerAlias www.robertgrab.com webmail.robertgrab.com admin.robertgrab.com lists.robertgrab.com server3.robertgrab.com
DocumentRoot /home/grab/public_html
ErrorLog /var/log/virtualmin/robertgrab.com_error_log
CustomLog /var/log/virtualmin/robertgrab.com_access_log combined
ScriptAlias /cgi-bin/ /home/grab/cgi-bin/
ScriptAlias /awstats /home/grab/cgi-bin
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/grab/public_html>
Options -Indexes IncludesNOEXEC FollowSymLinks
allow from all
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /home/grab/fcgi-bin/php5.fcgi .php
</Directory>
<Directory /home/grab/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.robertgrab.com
RewriteRule ^(.) https://robertgrab.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.robertgrab.com
RewriteRule ^(.
) https://robertgrab.com:10000/ [R]
Alias /dav /home/grab/public_html
Alias /pipermail /var/lib/mailman/archives/public
<Location /dav>
DAV On
AuthType Basic
AuthName robertgrab.com
AuthUserFile /home/grab/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
</Location>
<Files awstats.pl>
AuthName "robertgrab.com statistics"
AuthType Basic
AuthUserFile /home/grab/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/])(.) https://robertgrab.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
RedirectMatch /mailman/([^/])(.) https://robertgrab.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
</VirtualHost>
<VirtualHost 111.111.246.121:443>
SuexecUserGroup "#1001" "#1002"
ServerName robertgrab.com
ServerAlias www.robertgrab.com
ServerAlias webmail.robertgrab.com
ServerAlias admin.robertgrab.com
ServerAlias lists.robertgrab.com
DocumentRoot /home/grab/public_html
ErrorLog /var/log/virtualmin/robertgrab.com_error_log
CustomLog /var/log/virtualmin/robertgrab.com_access_log combined
ScriptAlias /cgi-bin/ /home/grab/cgi-bin/
ScriptAlias /awstats /home/grab/cgi-bin
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/grab/public_html>
Options -Indexes IncludesNOEXEC FollowSymLinks
allow from all
</Directory>
<Directory /home/grab/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.robertgrab.com
RewriteRule ^(.) https://robertgrab.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.robertgrab.com
RewriteRule ^(.
) https://robertgrab.com:10000/ [R]
SSLEngine on
SSLCertificateFile /home/grab/ssl.cert
SSLCertificateKeyFile /home/grab/ssl.key
Alias /dav /home/grab/public_html
Alias /pipermail /var/lib/mailman/archives/public
<Location /dav>
DAV On
AuthType Basic
AuthName robertgrab.com
AuthUserFile /home/grab/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
</Location>
<Files awstats.pl>
AuthName "robertgrab.com statistics"
AuthType Basic
AuthUserFile /home/grab/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/])(.) https://robertgrab.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
RedirectMatch /mailman/([^/])(.) https://robertgrab.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
</VirtualHost>

I created a wrapper ~/fcgi-bin/php5.fcgi. It is owned by the user and is executable and not writable by g/o. I copied php.ini from /etc/php5/apache2 to ~/user/etc/php5. I added 2 lines to the apache directives under the public_html section.

My php scripts still donā€™t work. I get 403 errors on them, although they have the correct user and group and have exec permissions. Any suggestions?

This is my virtual host file:

<VirtualHost 111.111.246.121:80>
SuexecUserGroup "#1001" "#1002"
ServerName robertgrab.com
ServerAlias www.robertgrab.com webmail.robertgrab.com admin.robertgrab.com lists.robertgrab.com server3.robertgrab.com
DocumentRoot /home/grab/public_html
ErrorLog /var/log/virtualmin/robertgrab.com_error_log
CustomLog /var/log/virtualmin/robertgrab.com_access_log combined
ScriptAlias /cgi-bin/ /home/grab/cgi-bin/
ScriptAlias /awstats /home/grab/cgi-bin
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/grab/public_html>
Options -Indexes IncludesNOEXEC FollowSymLinks
allow from all
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /home/grab/fcgi-bin/php5.fcgi .php
</Directory>
<Directory /home/grab/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.robertgrab.com
RewriteRule ^(.) https://robertgrab.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.robertgrab.com
RewriteRule ^(.
) https://robertgrab.com:10000/ [R]
Alias /dav /home/grab/public_html
Alias /pipermail /var/lib/mailman/archives/public
<Location /dav>
DAV On
AuthType Basic
AuthName robertgrab.com
AuthUserFile /home/grab/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
</Location>
<Files awstats.pl>
AuthName "robertgrab.com statistics"
AuthType Basic
AuthUserFile /home/grab/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/])(.) https://robertgrab.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
RedirectMatch /mailman/([^/])(.) https://robertgrab.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
</VirtualHost>
<VirtualHost 111.111.246.121:443>
SuexecUserGroup "#1001" "#1002"
ServerName robertgrab.com
ServerAlias www.robertgrab.com
ServerAlias webmail.robertgrab.com
ServerAlias admin.robertgrab.com
ServerAlias lists.robertgrab.com
DocumentRoot /home/grab/public_html
ErrorLog /var/log/virtualmin/robertgrab.com_error_log
CustomLog /var/log/virtualmin/robertgrab.com_access_log combined
ScriptAlias /cgi-bin/ /home/grab/cgi-bin/
ScriptAlias /awstats /home/grab/cgi-bin
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/grab/public_html>
Options -Indexes IncludesNOEXEC FollowSymLinks
allow from all
</Directory>
<Directory /home/grab/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.robertgrab.com
RewriteRule ^(.) https://robertgrab.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.robertgrab.com
RewriteRule ^(.
) https://robertgrab.com:10000/ [R]
SSLEngine on
SSLCertificateFile /home/grab/ssl.cert
SSLCertificateKeyFile /home/grab/ssl.key
Alias /dav /home/grab/public_html
Alias /pipermail /var/lib/mailman/archives/public
<Location /dav>
DAV On
AuthType Basic
AuthName robertgrab.com
AuthUserFile /home/grab/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
</Location>
<Files awstats.pl>
AuthName "robertgrab.com statistics"
AuthType Basic
AuthUserFile /home/grab/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/])(.) https://robertgrab.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
RedirectMatch /mailman/([^/])(.) https://robertgrab.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
</VirtualHost>

I created a wrapper ~/fcgi-bin/php5.fcgi. It is owned by the user and is executable and not writable by g/o. I copied php.ini from /etc/php5/apache2 to ~/user/etc/php5. I added 2 lines to the apache directives under the public_html section.

My php scripts still donā€™t work. I get 403 errors on them, although they have the correct user and group and have exec permissions. Any suggestions?

This is my virtual host file:

<VirtualHost 111.111.246.121:80>
SuexecUserGroup "#1001" "#1002"
ServerName robertgrab.com
ServerAlias www.robertgrab.com webmail.robertgrab.com admin.robertgrab.com lists.robertgrab.com server3.robertgrab.com
DocumentRoot /home/grab/public_html
ErrorLog /var/log/virtualmin/robertgrab.com_error_log
CustomLog /var/log/virtualmin/robertgrab.com_access_log combined
ScriptAlias /cgi-bin/ /home/grab/cgi-bin/
ScriptAlias /awstats /home/grab/cgi-bin
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/grab/public_html>
Options -Indexes IncludesNOEXEC FollowSymLinks
allow from all
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /home/grab/fcgi-bin/php5.fcgi .php
</Directory>
<Directory /home/grab/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.robertgrab.com
RewriteRule ^(.) https://robertgrab.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.robertgrab.com
RewriteRule ^(.
) https://robertgrab.com:10000/ [R]
Alias /dav /home/grab/public_html
Alias /pipermail /var/lib/mailman/archives/public
<Location /dav>
DAV On
AuthType Basic
AuthName robertgrab.com
AuthUserFile /home/grab/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
</Location>
<Files awstats.pl>
AuthName "robertgrab.com statistics"
AuthType Basic
AuthUserFile /home/grab/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/])(.) https://robertgrab.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
RedirectMatch /mailman/([^/])(.) https://robertgrab.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
</VirtualHost>
<VirtualHost 111.111.246.121:443>
SuexecUserGroup "#1001" "#1002"
ServerName robertgrab.com
ServerAlias www.robertgrab.com
ServerAlias webmail.robertgrab.com
ServerAlias admin.robertgrab.com
ServerAlias lists.robertgrab.com
DocumentRoot /home/grab/public_html
ErrorLog /var/log/virtualmin/robertgrab.com_error_log
CustomLog /var/log/virtualmin/robertgrab.com_access_log combined
ScriptAlias /cgi-bin/ /home/grab/cgi-bin/
ScriptAlias /awstats /home/grab/cgi-bin
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/grab/public_html>
Options -Indexes IncludesNOEXEC FollowSymLinks
allow from all
</Directory>
<Directory /home/grab/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.robertgrab.com
RewriteRule ^(.) https://robertgrab.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.robertgrab.com
RewriteRule ^(.
) https://robertgrab.com:10000/ [R]
SSLEngine on
SSLCertificateFile /home/grab/ssl.cert
SSLCertificateKeyFile /home/grab/ssl.key
Alias /dav /home/grab/public_html
Alias /pipermail /var/lib/mailman/archives/public
<Location /dav>
DAV On
AuthType Basic
AuthName robertgrab.com
AuthUserFile /home/grab/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
</Location>
<Files awstats.pl>
AuthName "robertgrab.com statistics"
AuthType Basic
AuthUserFile /home/grab/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/])(.) https://robertgrab.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
RedirectMatch /mailman/([^/])(.) https://robertgrab.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2
</VirtualHost>

For Debian and Virtualmin GPL the drill is like this:

wget http://software.virtualmin.com/gpl/scripts/install.sh
chmod +x install.sh
./install.sh
apt-get install php5-mysql
mkdir /etc/skel/fcgi-bin
vi /etc/skel/fcgi-bin/php5.fcgi

#!/bin/bash
PHPRC=$PWD/ā€¦/etc/php5
export PHPRC
umask 022
SCRIPT_FILENAME=$PATH_TRANSLATED
export SCRIPT_FILENAME
exec /usr/bin/php-cgi

chmod +x /etc/skel/fcgi-bin/php5.fcgi
mkdir /etc/skel/etc
mkdir /etc/skel/etc/php5
cp /etc/php5/apache2/php.ini /etc/skel/etc/php5/php.ini

Go to Virtualmin Ć¢

For Debian and Virtualmin GPL the drill is like this:

wget http://software.virtualmin.com/gpl/scripts/install.sh
chmod +x install.sh
./install.sh
apt-get install php5-mysql
mkdir /etc/skel/fcgi-bin
vi /etc/skel/fcgi-bin/php5.fcgi

#!/bin/bash
PHPRC=$PWD/ā€¦/etc/php5
export PHPRC
umask 022
SCRIPT_FILENAME=$PATH_TRANSLATED
export SCRIPT_FILENAME
exec /usr/bin/php-cgi

chmod +x /etc/skel/fcgi-bin/php5.fcgi
mkdir /etc/skel/etc
mkdir /etc/skel/etc/php5
cp /etc/php5/apache2/php.ini /etc/skel/etc/php5/php.ini

Go to Virtualmin Ć¢