i have apache2 (Server version: Apache/2.4.7 (Ubuntu) Server built: Mar 10 2015 13:05:59), mysql and phpmyadmin.
While accessing php file by http://localhost/ or http://ipaddress
It shows up source code instead of executing.
Ubuntu 14.04 LTS
i have apache2 (Server version: Apache/2.4.7 (Ubuntu) Server built: Mar 10 2015 13:05:59), mysql and phpmyadmin.
While accessing php file by http://localhost/ or http://ipaddress
It shows up source code instead of executing.
Ubuntu 14.04 LTS
I can think of 3 possibilities:
You don't have PHP installed. In that case run:
sudo apt-get install php php-mysql
You have PHP installed but not enabled. You can try running:
sudo a2enmod php7
sudo service apache2 restart
You have PHP installed and enabled but you haven't restarted apache.
sudo service apache2 restart
E: Unable to locate pachage php
I tried with php5 which gives php5 is already the newest version.
2 . ERROR: Module php5 does not exist!
. I tried with php which gives same error. 3 The apache2 configtest failed.
sudo apt-get purge apache2 php5 mysql-server
This will completely remove the packages including their configuration files so if you have made any important changes better make a backup of /etc/apache2 , /etc/mysql and /etc/php5 first. After that do the following: sudo apt-get install apache2 php5 mysql-server
. Note that it is important to install them all at once because otherwise modphp doesn't always get installed.
Jun 9, 2015 at 19:10
libapache2-mod-php5
.
you need to install libapache2-mod-php
sudo apt-get install libapache2-mod-php
it is no longer pulled by other packages as a dependency
in 14.04 it named libapache2-mod-php5, in 16.04 they dropped the number at the end for a meta package
For Ubuntu 20.04, I had to run:
sudo a2dismod mpm_event
It tells you to restart Apache2, but you don't need to at this point. Then enable php 7.4 using:
sudo a2enmod php7.4
Then restart Apache2: sudo systemctl restart apache2
Hope this helps!
After Upgrading to Ubuntu 17.10 this morning my answer was a combination of Sledge Hammer's and GM-Script-Writer-62850's answer. The exact commands I needed were:
sudo apt-get install libapache2-mod-php
sudo a2enmod php7.1
systemctl restart apache2
After upgrading to Ubuntu 20.04 to 22.04, I also faced this problem and after reinstall phpmyadmin not working but i searched for 1-2 hours and finally this work for me. I have php 8.1 and mysql 8.0
sudo add-apt-repository ppa:ondrej/php
sudo apt-get install libapache2-mod-php8.1
sudo a2enmod php8.1
systemctl restart apache2