简体   繁体   中英

PHP code downloading instead of running on Apache server

So I'm new to server setup and I'm trying to get PHP 7.2 to run on an Ubuntu 18.04.3 LTS-based Apache2 server. I have a simple phpinfo file:

<?php phpinfo(); ?>

which, when visited in a browser, downloads the file instead of running it.

Below are all of the steps I've followed thus far:

  • Installed PHP7.2, Apache2, and libapache2-mod-php7.2 using apt-get
  • Enabled PHP7.2 in Apache: php7.2.conf and php7.2.load are present in apache2/mods-enabled/ and mods-available/
  • Updated all packages
  • Enabled short tags
  • PHP is not running in a user directory
  • Apache server restarted after every change
  • mod-php.so seems to be missing from the Apache modules folder?

httpd.conf was not present; I created it manually and added the following lines to it:

AddHandler application/x-httpd-php .php .phtml
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

apache2.conf:

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

Any ideas as to what I might still be missing?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM