1
votes

I have followed the instructions from this site after installing lamp server on ubuntu 14.04 - https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-14-04

When I type this in my webbrowser - localhost/phpmyadmin - the page is filled with php code.

2
It sounds like you didn't get Apache configured correctly or get the PHP module for it installed. Can you post your httpd.conf file? - HeadCode
Yeah sure.. But could you check this out and tell me if i should do what is told in the first answer? - askubuntu.com/questions/387062/… - Niraj Pandkar
Ok I tried doing that but nothing worked.. guess I will put the httpd.conf.. But could you tell me what really should i look for or edit in the httpd file so as to get it working instead of pasting all of it on the net ? - Niraj Pandkar

2 Answers

0
votes

OK, this isn't really an answer but it's more than a comment. In your httpd.conf file make sure you have this line and that it is not commented out:

LoadModule php5_module        modules/libphp5.so

That should be near the top of the file. Much further down you'll see some AddHandler lines. Make sure you have this:

 AddHandler php5-script .php

You also might want to look to make sure this directive is in place. It gives Apache a clue for what file to try to serve if you navigate to a directory instead of a file:

 <IfModule dir_module>
     DirectoryIndex index.php
 </IfModule>

Don't forget to restart Apache after changing your httpd.conf file.

For your installation specifically make sure you have the following files:

/etc/apache2/mods-enabled/php5.conf
/etc/apache2/mods-enabled/php5.load

When you were going through the steps of installing your LAMP stack did you do the test of creating the info.php file? I just created an Ubuntu 14.4 VM and followed all the steps and it worked for me the first time. Try going back through all those steps and double checking everything.

0
votes

I want to thank HeadCode for taking interest in my question.

The real problem was to find why localhost/phpmyadmin was returning php code. It depends on a lot of things but in my case the problem lied in the php5.conf file which resides in etc/apache2/mods-enabled/php5-conf.

The php.conf file contents are as follows -

# Running PHP scripts in user directories is disabled by default
# 
# 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_flag engine Off
    </Directory>
</IfModule>

As you can see if you want enable php you just have to comment the code so that it looks something like this -

# Running PHP scripts in user directories is disabled by default
# 
# 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_flag engine Off
#    </Directory>
#</IfModule>

This addressed the issue at least for me.