最初的问题是服务器上的PHP文件显示为纯文本(显示了整个代码).因此,我通过调查发现必须将MIME类型添加到/etc/mime.types中,从而做到了这一点,并且还重新启动了服务器,但这无助于解决问题,因此我从here,我们需要启用php5模块,并且在运行apachectl -M时,我找不到列出的php5模块.所以我尝试安装它,这就是它的结果:
admin@vm:~$sudo apt-get install php5
...
php5_invoke pdo: already enabled for apache2 SAPI
dpkg: error processing package 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)
admin@vm:~$sudo apt-get install libapache2-mod-php5
...
dpkg: error processing package 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)
我还需要提到我为站点创建了2个虚拟主机.我不确定是怎么了.有人可以帮我吗?
解决方法:
这不是一个适当的解决方案,但是我重新安装了Apache,它运行良好:
$sudo apt-get purge apache2
$sudo apt-get purge php5 libapache2-mod-php5
$sudo apt-get purge autoremove
$sudo apt-get install apache2 libapache2-mod-php5 php5
标签:apache,php
来源: https://codeday.me/bug/20191027/1944833.html