php 文件未在 apache 2 中运行

php 文件未在 apache 2 中运行

我正在尝试使用 netbeans 运行 php,当我尝试运行它时,echophp 无法在浏览器中运行,但 html 文件可以正常运行

我的代码

<html>
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>jjjjjj
    <?php        
    echo 'hello world';
    ?>
</body>
</html>

只有jjjjjj来了。

当我在终端中输入 php -v 时,会出现

PHP 7.0.4-7ubuntu2 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

我搜索了 php 问题并尝试安装 php,但是

sudo apt-get install apache2 php5 libapache2-mod-php5
Reading package lists... Done
Building dependency tree       
Reading state information... Done
apache2 is already the newest version (2.4.18-2ubuntu3).
php5 is already the newest version (5.3.2-1ubuntu4).
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 dbus : Depends: adduser but it is not going to be installed
 dpkg : Breaks: libapache2-mod-php5 (< 5.6.4+dfsg-3~) but 5.3.2-1ubuntu4 is to be installed
 libapache2-mod-php5 : Depends: apache2-mpm-prefork (> 2.0.52) but it is not going to be installed or
                                apache2-mpm-itk but it is not installable
                       Depends: apache2.2-common but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

问题出在 php7 还是 php5?

请帮我

答案1

从您的日志来看,似乎旧版本的软件包(可能是非官方的)在安装过程中导致了问题。

这里的解决方案很好地解释了您的问题的答案:askubuntu:libapache-mod5-php- 安装问题

按照那里的解决方案操作。如果存在问题,请发表评论。

相关内容