[英].php files downloading instead of executing
I am brand new to Apache and PHP. 我是Apache和PHP的新手。
I created a helloworld.php file and when I run it, the file downloads and the command is never executed. 我创建了一个helloworld.php文件,当我运行它时,文件下载并且命令永远不会执行。
I use Ubuntu 16.04 with Apache 2 and PHP 7.1 . 我使用Ubuntu 16.04与Apache 2和PHP 7.1。
I tried completely reinstalling everything and also editing the apache2.conf file with this : 我尝试完全重新安装所有内容,并使用以下方法编辑apache2.conf文件:
<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 我尝试从以下网址安装LAMP: 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 : 但是在最后一步中,我使用以下代码行创建了一个info.php文件:
<?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. 我尝试找到解决方案,但大多数都提到了httpd.conf文件,我无法在任何地方找到它。
I know this question has been asked multiple times before, but I didn't find a satisfactory solution. 我知道这个问题之前已被多次询问过,但我没有找到满意的解决方案。
Seems like apache PHP module is not installed. 好像没有安装apache PHP模块。 First of all install apache php module from following command:
首先从以下命令安装apache php模块:
sudo apt install php libapache2-mod-php
And then enable the module with following command: 然后使用以下命令启用该模块:
sudo a2enmod php7.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.