UserDirectoryPHP

Differences between revisions 6 and 7
Revision 6 as of 2006-04-28 08:26:56
Size: 1142
Editor: rrcs-24-153-226-7
Comment:
Revision 7 as of 2006-04-28 10:12:11
Size: 1552
Editor: rrcs-24-153-226-7
Comment:
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
sudo a2enmod userdir
Line 21: Line 22:
Enable Apache's handling of PHP files. Uncomment the following line from /etc/apache2/apache2.conf:
{{{AddType application/x-httpd-php .php
Enable Apache's handling of PHP files. Add the following line to /etc/apache2/apache2.conf
{{{AddHandler cgi-script .php
Line 25: Line 26:
Add an action to handle PHP files. Add the following line beneath the one just uncommented:
{{{Action application/x-httpd-php /cgi-bin/php5
}}}
Configure the userdir module. Uncomment the following lines in /etc/apache2/apache2.conf.
{{{UserDir public_html
UserDir disabled root

<Directory /home/*/public_html>
 AllowOverride FileInfo AuthConfig Limit
 Options Indexes SymLinksIfOwnerMatch IncludesNoExec
</Directory>}}}

Add the ExecCGI option. The block should now appear as below.
{{{UserDir public_html
UserDir disabled root

<Directory /home/*/public_html>
 AllowOverride FileInfo AuthConfig Limit
 Options Indexes SymLinksIfOwnerMatch IncludesNoExec ExecCGI
</Directory>}}}

Introduction

This procedure installs PHP 5 and Apache 2 and configures Apache (and the shell) to run PHP scripts as CGIs. This is an alternative to using PHP as a module in Apache.

Procedure

Install Apache 2 and PHP 5. {{{sudo apt-get install apache2 php5-cgi }}}

Configure PHP 5 to run .php scripts from the shell. {{{sudo update-binfmts --install PHP /usr/bin/php5-cgi --extension php }}}

Enable necessary Apache modules.

{{{sudo a2enmod actions sudo a2enmod rewrite sudo a2enmod suexec sudo a2enmod include sudo a2enmod userdir sudo a2enmod ssl}}}

Enable Apache's handling of PHP files. Add the following line to /etc/apache2/apache2.conf {{{AddHandler cgi-script .php }}}

Configure the userdir module. Uncomment the following lines in /etc/apache2/apache2.conf. {{{UserDir public_html UserDir disabled root

<Directory /home/*/public_html>

</Directory>}}}

Add the ExecCGI option. The block should now appear as below. {{{UserDir public_html UserDir disabled root

<Directory /home/*/public_html>

</Directory>}}}

Reload the Apache configuration. {{{sudo /etc/init.d/apache2 force-reload }}}

Notes

If implemented as described, this configuration requires accessing phpMyAdmin via {{{http://localhost/phpmyadmin/index.php }}} http://localhost/phpmyadmin/ will not work.