我正在升级我的发行版,从kali(wheezy)到sid。但是当我设置我的Web服务器时,我重新安装了所有,apache2,php,mysql等,但是当我访问localhost/phpmyadmin
时我收到此错误:该URL未显示phpmyadmin的索引/登录页面,但显示代码。在我的/var/www
中,默认为index.html,我将其重命名为index.php,没关系,页面已加载,我对/var/www
中的其他目录执行相同操作我添加了index.php或foo.php并访问它,没问题,但是当我输入phpmyadmin
时它会显示代码。我尝试安装phpminiadmin
和adminer
,但我得到了相同的错误,两者都显示代码而不是网页。
这是我的apache2.conf
http://pastebin.com/MLYNQc6S
这是我的规格:
#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-php5filter
和libapache2-mod-php5
的包,我检查一下,安装它,成功,没有发现错误,
我重新启动apache2并转到localhost/phpmyadmin
及其工作。
谢谢你的哑光。
答案 0 :(得分:7)
请检查下面的内容,从一些差异链接找到你:
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
感谢
答案 1 :(得分:3)
试试这个
sudo apt-get install libapache2-mod-php7.0
这将为apache2安装库以使用php7.0
答案 2 :(得分:1)
在我的情况下,这是由于事实之后我安装了apache2,然后未链接并激活了适当的php mod。您需要做什么:
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/php7.2.conf
sudo ln -s ../mods-available/php7.2.load
然后,您只需重新启动服务器即可:
sudo systemclt restart apache2
答案 3 :(得分:0)
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
service apache2 restart
libapache2-mod-php服务器端,HTML嵌入式脚本语言(Apache 2模块)所以我们必须添加
答案 4 :(得分:0)
如果所有其他PHP页面运行正常,则可能不是与PHP相关的问题。
由于只有phpmyadmin登录页面显示的是php代码而不是实际登录页面,因此,您的apache网络根目录/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
(或者将其删除并重新创建:)
$ sudo unlink /var/www/html/phpmyadmin
$ sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
答案 5 :(得分:0)
我在Debian 10(破坏者)和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模块不可用。