Saturday, August 31, 2013

Enabling php from within public_html

Started learning php and tried out the basic project from netbeans sdk. It copies the php files into
$HOME/public_html/phpProject.

http://localhost/username/phpProject causes the index.php to download rather than render on the browser.

To change this behavior and get your first php from public_html to render correctly you need
to modify the /etc/apache2/mods-enabled/php5.conf file. Find and comment out the following
set of lines from the said file:



 # To re-enable php in user directories comment the following lines
 # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
 # prevents .htaccess files from disabling it.
 <IfModule mod_userdir.c>
        <Directory /home/*/public_html>
            php_admin_value engine Off
        </Directory>
    </IfModule>
 </IfModule>

You might have to restart apache after this change. That should get you going.

References

http://devplant.net/2010/05/04/linux-php-not-working-in-userdir-public_html/