You don't need to compile PHP if you already installed LAMP as PHP is run in the server itself, you need just to invoke the files in the proper place as @MustafaJF mention.
Simply open nautilus
with administrative privileges by executing (in a terminal or by hitting Alt-F2 for the run program dialog), write gksudo nautilus
, provide your password and go to the /var/www
folder, over there simply drop your php files which you can access later by opening a web browser and pointing to the http://localhost/foldername/yourphpfile.php
address.
Where foldername
is the folder where the php files will reside and yourphpfile.php
is the file containing your php code.
A good example to test if everything is running fine is the to create a file with the next contents inside:
<?php
phpinfo();
?>
Let's name this file phpinfo.php
and place it at the very root of /var/www
folder, after which we'll invoke it via http://localhost/phpinfo.php
and will result in something like this:

Results may vary from case to case.
Remember that /var/www
is a protected place of which you will need administrative privileges each time you want to access the files for a change or something. But if you prefer, you can (at your own risk) change the location of your /var/www
to a different place for testing purposes, which will suppose no risk at all if you do it just for testing purposes and have your server not exposed to the net. See this answer for a workaround to change the default location of your testing server.
Please inform if you are experiencing any issues.
Good luck!
you may need to disable the proxy_fcgi
apache module:
sudo a2dismod proxy_fcgi proxy; sudo service apache2 restart
- 1. Re-Install PHP 5.6
Actually is not required to remove php7.0
, you can install php5.6 together ( also because you will have dependency problem with phpmyadmin
package that required php7.0)
Assuming libapache2-mod-php
is a suitable way to enable PHP in Apache for you, you can proceed in this way:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0
Best Answer
You can use a php version manager to achieve this. Different version managers are available like:
My favorite is phpbrew. Hope this helps.