Since i move to Ubuntu recently, i need to setup all the development environment. My stack is using Nginx with Apache + PHP as the webserver and use MySQL as database. Since i don’t like to use
1 | /var/www |
as the home directory for the apache, i moved it to my /home/ivan/public_html folder. And to make it easier, i need to change PHP to run as my user role. For that i install suPHP module on Apache, and then chmod 755 all the php files.
Everything is working correctly, except PHPMyAdmin, since it is installed in
1 | /usr/share/phpmyadmin |
, and all the files and folders under root permissions. So when Apache run it, it cannot run the PHP. To fix it i just edit the file
1 | /etc/apache2/mods-available/php5 .conf |
and add these line below:
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 | <Directory /usr/share > <IfModule mod_php5.c> <FilesMatch "\.ph(p3?|tml)$" > SetHandler application /x-httpd-php < /FilesMatch > <FilesMatch "\.phps$" > SetHandler application /x-httpd-php-source < /FilesMatch > # 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 > < /Directory > |
By adding those line, means the suPHP mod will not run if the root directory us /usr/share/
After that don’t forget to restart your Apache:
1 | sudo service apache2 restart |
And now the PHPMyadmin will work perfectly!