Apache2 does not run php

Asked

Viewed 402 times

0

Hello, good night!

I have installed in my PC Apache2 and php7.2. Only when I try to run a file.php in the browser Firefox it returns me the same file for me to download. I have already searched in Google the solution to this problem but none of the presented solved.

The code is simple:

<<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" media="screen" href="main.css" />
    <script src="main.js"></script>
</head>
<body>
    <?php echo "Olá mundo!"; ?>
</body>
</html>

So, I appreciate any help!

  • Did you put the file in the folder that distributes it to the web? is accessing the url provided by apache?

  • 1

    The url I use is this : localhost/myprogram/file.php.

  • which operating system?

  • 1

    Ubuntu 18.04 LTS

1 answer

1

You need to remove a comment in this file /etc/apache2/httpd.conf. I’ve had this problem and it’s solved.

LoadModule php5_module libexec/apache2/libphp7.so

if it doesn’t work try adding it to your . htaccess

AddType application/x-httpd-php .php

Another option is to try to install php mod

apt-get install libapache2-mod-php

If any of the above works comments below, it can help other people!

  • Yeah, I can’t find this httpd.conf, it’s the same as apache2.conf?

  • That’s right, in Ubuntu is that file.

  • Unfortunately it didn’t work. It says I don’t have permissions to change the file

  • I can’t find this comment in the file : Loadmodule php5_module libexec/apache2/libphp7.so

  • Rotate this control then, sudo apt-get install php libapache2-mod-php you haven’t installed php yet

  • php has already been installed. However, it still remains the same error.

  • Runs the above command to install its extension in apache and then restarts apache sudo service apache2 restart take the test and see if the result is the same

  • Unsuccessful. I will uninstall and install again.

  • Do this, use this installation. sudo add-apt-repository ppa:ondrej/php&#xA;sudo apt-get update&#xA;sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-mcrypt php7.0-mysql

  • I did it, but it’s still the same.

  • sudo a2enmod php7&#xA;sudo service apache2 restart

  • Unfortunately it didn’t work. Still it keeps displaying a dialog box for me to download.php file.

  • @Ícarotimothy this dialog box can update the question and put a print of it.

  • It is the one when you will download anything, be it file, music, video etc.

Show 9 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.