5

I recently configured php7 on Ubuntu 14.04 by following blog http://www.zimuel.it/install-php-7 and I installed it successfully as per blog. but when try to run the php file (/var/www/test.php) then it is downloaded instead of executing. I have no idea what configuration I missed. and when I entered localhost in browser then it comes with response "it works".

sameer.nuna
  • 454
  • 1
  • 5
  • 6

4 Answers4

2

(Edit) I had a similar problem that first looked like that Apache randomly showed me correct data and sometimes gave me a download option. It showed up that it was completely different processes that competed about answering to port 80. Killing everything alive fixed that problem and this has actually very little to do with the real problem. So the rows below actually solved the download-problem for me, at last.

LoadModule php7_module        modules/libphp7.so
AddHandler php7-script .php
AddType application/x-httpd-php-source .phps
AddHandler application/x-httpd-php .phps
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php
2

In your apache configuration in /etc/apache2/sites-available try to remove this lines with comments:

#RemoveHandler .php
#RemoveHandler .php7.0
#php_admin_value engine Off
TomoMiha
  • 1,218
  • 1
  • 14
  • 12
1

I was having the same issue on my Ubuntu 18.04. I fixed the issue by performing the following steps.

Step 1: Check if php7 module is present in /etc/apache2/mods-available. If there are files like php7.conf and php7.load perform step 3, else go to the next step.

Step 2: Download the php7 module for apache. I had php7.2 installed so I installed the module by doing sudo apt-get install libapache2-mod-php7.2. You can replace the php version in your command with the one you have installed.

Step 3: Enable the apache module. sudo a2enmod php7.2 in my case.

Step 4: Restart apache server by doing sudo service apache2 restart.

SUB0DH
  • 5,130
  • 4
  • 29
  • 46
0

You need to enable PHP under Apache, like so:

sudo a2dismod php5

sudo service apache2 restart

sudo cp /etc/apache2/mods-available/php5.conf /etc/apache2/mods-enabled/php7.conf

sudo service apache2 restart

From: http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu

Community
  • 1
  • 1
user2182349
  • 9,569
  • 3
  • 29
  • 41
  • I have already done this. and its also showing correct version on terminal with command php-src/sapi/cli/php -v. but not working with browser. when I checked error.log it shows [Sun Dec 13 13:23:43.132843 2015] [mpm_prefork:notice] [pid 4857] AH00169: caught SIGTERM, shutting down [Sun Dec 13 13:23:44.234203 2015] [mpm_prefork:notice] [pid 11020] AH00163: Apache/2.4.10 (Ubuntu) configured -- resuming normal operations [Sun Dec 13 13:23:44.234324 2015] [core:notice] [pid 11020] AH00094: Command line: '/usr/sbin/apache2' – sameer.nuna Dec 13 '15 at 08:25
  • im not sure if i want to try this, maybe thats why no points. Can you offer a brief explanation before taking off to a url, so users can have a better glimpse of it, e.g. what does `a2dismod` do, will this work for 7.2 even though your passing `php5` . I dont have an /etc/apache, using centos, but have httpd `etc/httpd/modules`, and not seeing that file – blamb Oct 22 '18 at 18:34
  • a2dismod is an Ubuntu way to disable Apache modules – user2182349 Oct 22 '18 at 21:09
  • If you need help with PHP 7.2 under CentOS, you should create a new question and include more information. – user2182349 Oct 22 '18 at 21:15