3

I am brand new to Apache and PHP.

I created a helloworld.php file and when I run it, the file downloads and the command is never executed.

I use Ubuntu 16.04 with Apache 2 and PHP 7.1 .

I tried completely reinstalling everything and also editing the apache2.conf file with this :

<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>

But this did not work.

I tried installing LAMP from : https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04

But during the last step, I created an info.php file with these lines of code :

<?php
phpinfo();
?>

And the above lines were displayed as it is.

I tried finding the solution, but most of them mention a httpd.conf file, which I am not able to find anywhere.

I know this question has been asked multiple times before, but I didn't find a satisfactory solution.

10
  • Are you sure php is installed ? Commented Jun 14, 2017 at 14:35
  • Yes I am sure. I have checked it. Commented Jun 14, 2017 at 14:39
  • do you have an /etc/apache2/mods-available/php7.* set of files ? if yes, you have to a2enmod php7 (on Debian, not certain about Ubuntu). Commented Jun 14, 2017 at 14:41
  • so where did you put this php file you created ? You have to put it in www directory. Commented Jun 14, 2017 at 14:42
  • 1
    mind telling us how you're accessing those files? Are you doing http://localhost/file.php or file:///file.php directly in the browser? @HarshBhardwaj Commented Jun 14, 2017 at 14:44

1 Answer 1

2

Seems like apache PHP module is not installed. First of all install apache php module from following command:

sudo apt install php libapache2-mod-php

And then enable the module with following command:

sudo a2enmod php7.0
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.