简体   繁体   English

Apache2无法打开.php文件

[英]Apache2 cannot open .php files

I installed lamp long time ago and was able to execute php files. 我很早以前安装了lamp,并且能够执行php文件。 However, recently I tried to install cakePHP and ran into trouble (restarting apache started to generate errors). 但是,最近我尝试安装cakePHP并遇到麻烦(重新启动Apache开始产生错误)。 Thus I purged apache2 from my system. 因此,我从系统中清除了apache2。 I reinstalled apache2 using command "apt-get install apache2" but after doing so it could no longer open .php files, shows a blank page instead. 我使用命令“ apt-get install apache2”重新安装了apache2,但这样做后它将无法再打开.php文件,而是显示空白页。 I've set the necessary permissions (given -R 777 to /etc and /var/www). 我已经设置了必要的权限(将/ R和/ var / www赋予-R 777)。 I've also ran the command "apt-get install php7.0 libapache2-mod-php7.0" and restarted apache several times, nothing works. 我还运行了“ apt-get install php7.0 libapache2-mod-php7.0”命令,并重新启动了apache几次,没有任何效果。 Can anyone help? 有人可以帮忙吗?

PS: I was originally trying to run phpmyadmin, before purging I was able to run it but after reinstalling it threw errors, thence I discovered my server was not able to execute any php file. PS:我本来是试图运行phpmyadmin的,但在清除之前我可以运行它,但是重新安装后却抛出了错误,因此我发现我的服务器无法执行任何php文件。 Additionally, when I access the file (home.php) via localhost/home.php it shows a blank page but if follow the path file:///var/www/html/home.php it brings a pop up that asks me to either save or open the script. 另外,当我通过localhost / home.php访问文件(home.php)时,它会显示一个空白页,但是如果按照路径file:///var/www/html/home.php进行操作,则会弹出一个对话框,询问我保存或打开脚本。

I think problem is the apache-php-mod is not well installed,I suggest you purge remove all apache and php package,then reinstall them. 我认为问题是apache-php-mod安装不正确,建议您清除所有apache和php软件包,然后重新安装。

sudo apt-get purge apache2
sudo apt-get purge php
sudo apt-get autoremove

Then,find all apache2 or php files, and remove them,you can do it by using find command,be carefully when do this! 然后,找到所有apache2或php文件,并将其删除,您可以使用find命令执行此操作,在执行此操作时请务必小心!

sudo find / -name apache2

At last,you can reinstall them 最后,您可以重新安装它们

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM