php phpmyadmin 显示代码而不是网页
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20739350/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
phpmyadmin displays code not web page
提问by 3118731
I was upgrading my distro, from kali(wheezy) to sid. But when I was setting up my web server, I reinstalled all over, apache2, php, mysql etc., but I get this error when I access localhost/phpmyadmin: that URL is not showing an index / login page of phpmyadmin, but showing the code. In my /var/wwwthe default is index.html, I renamed it to index.php, and it's ok, page is loaded, I do the same with my other directory in /var/wwwI added index.php or foo.php and access it, no problem, but when I enter phpmyadminit's showing code. I tried installing phpminiadminand adminer, but I get the same error, both are showing the code and not the web page.
我正在升级我的发行版,从 kali(wheezy) 到 sid。但是当我设置我的网络服务器时,我重新安装了 apache2、php、mysql 等,但是当我访问时出现这个错误localhost/phpmyadmin:那个 URL 没有显示 phpmyadmin 的索引/登录页面,而是显示了代码。在我/var/www的默认是index.html,我把它重命名为index.php /var/www,没问题,页面加载了,我对我的其他目录做同样的事情,我添加了index.php或foo.php并访问它,没问题,但是当我输入时,phpmyadmin它显示了代码。我尝试安装phpminiadmin和adminer,但出现相同的错误,两者都显示代码而不是网页。
Here is my apache2.confhttp://pastebin.com/MLYNQc6S
这是我的apache2.confhttp://pastebin.com/MLYNQc6S
And here is my 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
and no error found in my /var/log/apache2/*log
并且没有发现错误 my /var/log/apache2/*log
I found this Localhost/phpmyadmin/ returns php codebut didnt help.
我发现这个Localhost/phpmyadmin/ 返回 php 代码但没有帮助。
so whats wrong with my server ?
那么我的服务器有什么问题吗?
EDIT 1 :
Like @Matt said in first comment. libapache2-mod-php5is not installed, so I installing it with apt-getfrom repo.
编辑 1 :就像@Matt 在第一条评论中所说的那样。libapache2-mod-php5没有安装,所以我apt-get从 repo安装它。
apt-get install libapache2-mod-php5
but its return an error, like this.
但它返回一个错误,就像这样。
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)
I open synaptic and search for libapache2-mod-php5there are showing two package with that name libapache2-mod-php5filterand libapache2-mod-php5, I check it all, and install it, success, no error found,
i restart apache2 and go to localhost/phpmyadminand its work.
thanks for matt.
我打开突触和搜索libapache2-mod-php5有显示两个包使用该名称libapache2-mod-php5filter和libapache2-mod-php5,我检查了这一切,并安装它,成功,没有发现错误,我重新启动的Apache2,去localhost/phpmyadmin和它的工作。感谢马特。
回答by Krunal Shah
please check below things, have found for you from some diff links:
请检查以下内容,从一些差异链接中为您找到:
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
Or check http://php.net/install
thanks
谢谢
回答by The Farmer
Try this
尝试这个
sudo apt-get install libapache2-mod-php7.0
This installs the library for apache2 to use php7.0
这会为 apache2 安装库以使用 php7.0
回答by Max Gordon
In my case this was due to that I installed apache2 after the fact and then proper php mods hadn't been linked and thus activated. What you need to do:
在我的情况下,这是因为我事后安装了 apache2,然后没有链接正确的 php mods,因此没有激活。你需要做什么:
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/php7.2.conf
sudo ln -s ../mods-available/php7.2.load
Then you just do a restart of the server by executing the following command:
然后您只需通过执行以下命令重新启动服务器:
sudo systemctl restart apache2
回答by abhishek kumar
sudo apt install php libapache2-mod-php
sudo apt install php7.0-mbstring
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
service apache2 restart
after that
在那之后
gedit /etc/apache2/apache2.conf
gedit /etc/apache2/apache2.conf
add the following line
添加以下行
Include /etc/phpmyadmin/apache.conf
包括 /etc/phpmyadmin/apache.conf
service apache2 restart
服务 apache2 重启
libapache2-mod-php server-side, HTML-embedded scripting language (Apache 2 module) so we have to add this
libapache2-mod-php 服务器端,嵌入 HTML 的脚本语言(Apache 2 模块)所以我们必须添加这个

