2017-03-07 39 views
0

我刚刚从here(mini.iso)安装了一个新的ubuntu系统 我在安装过程中根本没有选择任何附加件。Apache不能编译php

这些都是我所执行这一步的命令: (忽略4 - 8) enter image description here

现在,我写了一个简单的PHP测试脚本(/var/www/html/index.php

<?php 

echo "Hello World"; 

?> 

然而,从另一台计算机调用该页面后,我从字面上得到的不是编译PHP从文件输出。

输出:

<?php 

echo "Hello World"; 

?> 

我已经重新启动的Apache2,没有变化。

Apache的版本:

Server version: Apache/2.4.7 (Ubuntu) 
Server built: Jul 15 2016 15:32:47 

PHP版本:

PHP 7.0.16-4+deb.sury.org~trusty+1 (cli) (built: Mar 2 2017 13:50:00) (NTS) 
Copyright (c) 1997-2017 The PHP Group 
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies 
    with Zend OPcache v7.0.16-4+deb.sury.org~trusty+1, Copyright (c) 1999-2017, by Zend Technologies 

Linux版本的:

Linux的Linux的3.13.0-110泛型#157 Ubuntu的SMP Mon Feb 20 11:55:25 UTC 2017 i686 i686 i686 GNU/Linux

我已经搜索了互联网,其他一些用户说检查文件httpd.conf是否加载PHP模块,但没有这样的文件。我通过使用find/-name "httpd.conf"搜索它没有结果。

+0

http://stackoverflow.com/questions/12142172/apache-shows-php-code-instead-of-executing – JustOnUnderMillions

+0

http://stackoverflow.com/questions/5121495/php-code-is-not-being -executed-instead-code-shows-on-the-page – JustOnUnderMillions

回答

1

您需要安装PHP apache2模块才能使用PHP。您可以通过键入命令

sudo apt-get install libapache2-mod-php 

之后重新启动Apache安装在你的终端libapache2-mod-php。它会解决你的问题。

+0

解决了这个问题,非常感谢。注意:您不必重新启动apache2服务器,因为这在安装过程中会自动发生。 – Black

+0

是的,你是对的。 @EdwardBlack –