gpt4 book ai didi

PHP 无法在 Ubuntu Apache 服务器上运行

转载 作者:可可西里 更新时间:2023-10-31 22:09:26 24 4
gpt4 key购买 nike

我刚刚在 Ubuntu 17.04 上安装了 php 和 apache 服务器,但我的 .php 文件在我的浏览器上不起作用。

索引.php:

<!DOCTYPE html>
<html>
<body>
<h1>Welcome!</h1>
<?php
echo "Hello World!";
?>
</body>
</html>

只有 Welcome! 出现在浏览器上,当我检查页面时,我看到 php 代码正在被注释。我已经启动了 apache 服务器,但仍然不知道出了什么问题。请帮帮我,谢谢!

$ php -v

PHP 7.0.15-1ubuntu4 (cli) (built: Feb 28 2017 21:33:59) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.15-1ubuntu4, Copyright (c) 1999-2017, by Zend Technologies

$ sudo/etc/init.d/apache2 status

apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Tue 2017-04-25 14:38:55 +07; 10min ago
Process: 11578 ExecStop=/usr/sbin/apachectl stop (code=exited, status=0/SUCCESS)
Process: 11604 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 11619 (apache2)
Tasks: 55 (limit: 4915)
Memory: 9.7M
CPU: 429ms
CGroup: /system.slice/apache2.service
├─11619 /usr/sbin/apache2 -k start
├─11663 /usr/sbin/apache2 -k start
└─11664 /usr/sbin/apache2 -k start

Apr 25 14:38:55 g5080 systemd[1]: Starting The Apache HTTP Server...
Apr 25 14:38:55 g5080 apachectl[11604]: AH00558: apache2: Could not reliably determin…sage
Apr 25 14:38:55 g5080 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

最佳答案

当你在 ubuntu 17.04 中

您可以按照以下步骤操作

sudo apt-get install apache2 php libapache2-mod-php7.0 mysql-server php-mbstring php7.0-mbstring phpmyadmin     //install
sudo service apache2 restart //restart

再试一次你的文件(index.php)

关于PHP 无法在 Ubuntu Apache 服务器上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43604755/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com