phpmyadmin显示代码不是网页

guicsvcw  于 2023-10-20  发布在  PHP
关注(0)|答案(6)|浏览(211)

我正在升级我的发行版,从kali(wheezy)升级到sid。但是当我设置我的Web服务器时,我重新安装了所有的apache 2,php,mysql等,但是当我访问localhost/phpmyadmin时,我得到了这个错误:该URL没有显示phpmyadmin的索引/登录页面,但显示了代码。在我的/var/www默认是index.html,我重命名为index.php,它的确定,页面加载,我做同样的与我的其他目录在/var/www我添加index.php或foo.php和访问它,没有问题,但当我输入phpmyadmin它显示代码.我尝试安装phpminiadminadminer,但我得到了相同的错误,都显示代码,而不是网页。
这是我的apache2.confhttp://pastebin.com/MLYNQc6S
这是我的spec:

#php -v
PHP 5.5.7-2 (cli) (built: Dec 13 2013 00:25:07) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans


# mysql --version
mysql  Ver 14.14 Distrib 5.5.33, for debian-linux-gnu (i686) using readline 6.2

# apache2 -v
Server version: Apache/2.4.6 (Debian)
Server built:   Aug 12 2013 18:20:23

uname -a
Linux angga.id 3.7-trunk-686-pae #1 SMP Debian 3.7.2-0+kali8 i686 GNU/Linux

my /var/log/apache2/*log中未发现错误
我找到了这个Localhost/phpmyadmin/ returns php code,但没有帮助。
我的服务器有什么问题?
编辑1:就像@Matt在第一条评论中说的那样。libapache2-mod-php5没有安装,所以我从repo安装了apt-get

apt-get install libapache2-mod-php5

但它返回一个错误,就像这样。

dpkg: error processing libapache2-mod-php5 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 libapache2-mod-php5
E: Sub-process /usr/bin/dpkg returned an error code (1)

我打开synaptic并搜索libapache2-mod-php5,有两个软件包显示名称为libapache2-mod-php5filterlibapache2-mod-php5,我检查了所有内容,并安装了它,成功,没有发现错误,我重新启动apache 2并转到localhost/phpmyadmin及其工作。谢谢马特。

wb1gzix0

wb1gzix01#

我在Debian 10(buster)和PHP 7.3.19.1以及apache2版本2.4.38和phpmyadmin 5.02中遇到了同样的问题。未解释文件usr/share/phpmyadmin/index.php。在验证了所有手动安装后,我运行了以下命令:

apt-get update
apt-get install libapache2-mod-php7.3
systemctl restart apache2

终于成功了apache2的PHP模块不可用。

q9rjltbz

q9rjltbz2#

sudo apt install php libapache2-mod-php
sudo apt install php7.0-mbstring
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
service apache2 restart

之后
gedit /etc/apache2/apache2.conf
添加以下行

包含/etc/phpmyadmin/apache.conf

服务apache 2重启

libapache 2-mod-php服务器端,HTML嵌入式脚本语言(Apache 2模块),因此我们必须添加此

qhhrdooz

qhhrdooz3#

在我的情况下,这是由于我安装了apache2后,事实上,然后适当的php mods没有被链接,因此激活。您需要做的是:

cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/php7.2.conf
sudo ln -s ../mods-available/php7.2.load

然后,您只需通过执行以下命令重新启动服务器:

sudo systemctl restart apache2
siv3szwd

siv3szwd4#

如果所有其他PHP页面都工作正常,那么这可能不是PHP相关的问题。
由于只有phpmyadmin登录页面显示php代码而不是实际的登录页面,所以很可能你的apache web根目录/var/www/html/phpmyadmin中的符号链接引用的是phpmyadmin索引文件/usr/share/phpmyadmin/index.php而不是phpmyadmin目录/usr/share/phpmyadmin
这是一个错误的符号链接:

$ ll /var/www/html
lrwxrwxrwx 1 root root  timestamp  phpmyadmin -> /usr/share/phpmyadmin/index.php

这是一个正确的符号链接:

$ ll /var/www/html
lrwxrwxrwx 1 root root  timestamp  phpmyadmin -> /usr/share/phpmyadmin/

如果符号链接不正确,请更改它:

$ sudo ln -sfn /usr/share/phpmyadmin /var/www/html/phpmyadmin

(Or删除它并重新创建它:)

$ sudo unlink /var/www/html/phpmyadmin
$ sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
hc2pp10m

hc2pp10m5#

试试这个

sudo apt-get install libapache2-mod-php7.0

这将安装apache2的库以使用php7.0

kxeu7u2r

kxeu7u2r6#

请检查下面的东西,已经找到了一些不同的链接给你:

1. Make sure that PHP is installed. This sounds silly, but you never   
    know.

 2. Make sure that the PHP module is listed and uncommented inside of your Apache's httpd.conf This should be something like
    LoadModule    php5_module "c:/php/php5apache2_2.dll" in the file.
    Search for    LoadModule php, and make sure that there is no comment
    (;) in front    of it.

 3. Make sure that the http.conf file has the PHP MIME type in it. This should be something like AddType application/x-httpd-php
    .php.    This tells Apache to run .php files as PHP. Search for
    AddType, and    then make sure there is an entry for PHP, and that
    it is uncommented.

 4. Make sure your file has the .php extension on it, otherwise it will not be executed as PHP.

 5. Make sure you are not using short tags in the PHP file (<?), these are deprecated, and usually disabled. Use <?php instead.
           Actually run your file over said webserver using an URL like http://localhost/file.php not via local access   
    file://localhost/www/file.php

或检查http://php.net/install
谢谢

相关问题