简体   繁体   English

PHP 代码下载而不是在 Apache 服务器上运行

[英]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.所以我是服务器设置的新手,我试图让 PHP 7.2 在 Ubuntu 18.04.3 基于 LTS 的 ZA0196A9286E6FB036FE5670D6446 服务器上运行。 I have a simple phpinfo file:我有一个简单的 phpinfo 文件:

<?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使用 apt-get 安装 PHP7.2、Apache2 和 libapache2-mod-php7.2
  • Enabled PHP7.2 in Apache: php7.2.conf and php7.2.load are present in apache2/mods-enabled/ and mods-available/在 Apache 中启用 PHP7.2:php7.2.conf 和 php7.2.load 存在于 apache2/mods-enabled/ 和 mods-available/
  • Updated all packages更新了所有包
  • Enabled short tags启用短标签
  • PHP is not running in a user directory PHP 未在用户目录中运行
  • Apache server restarted after every change Apache 服务器在每次更改后重新启动
  • mod-php.so seems to be missing from the Apache modules folder? Apache 模块文件夹中似乎缺少 mod-php.so?

httpd.conf was not present; httpd.conf 不存在; 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: apache2.conf:

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

Any ideas as to what I might still be missing?关于我可能仍然缺少什么的任何想法?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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