Apache不执行PHP文件,但让我下载它们
所以我使用本教程设置我的服务器,当我使用服务器的IP输入地址时test.php文件没有问题。
http://1.2.3.4/test.php
但是,如果我使用虚拟主机,浏览器只提供下载文件而不是执行它。 所以这:
http://blog.mydomain.com/test.php
提供下载文件而不是执行脚本。
我在/etc/apache2/apache2.conf中用于虚拟主机的代码如下:
Include /etc/phpmyadmin/apache.conf Include /etc/apache2/mods-available/php5.conf DocumentRoot /path/to/vhosts/folder1 ServerName www.mydomain.com DocumentRoot /path/to/vhosts/folder2 ServerName blog.mydomain.com NameVirtualHost *:80
虽然我不得不说,当我重新启动apache2服务器时,我收到一条警告消息:
[....] Restarting web server: apache2 [Sun Jan 19 13:33:40 2014] [warn] NameVirtualHost *:80 has no VirtualHosts ... waiting [Sun Jan 19 13:33:41 2014] [warn] NameVirtualHost *:80 has no VirtualHosts
我得到它与该行:
sudo apt-get install libapache2-mod-php7.0 sudo service apache2 restart
有时更糟糕的事情可能发生….我只是忘了安装PHP
我在这里找到了解决方案。 事实certificate我必须启用一些模块……
取自user1075581的 Stack Overflow回答 :
这最终让我走上了正确的道路:
这是解决方案:
在
部分中,我包含以下行:
php_admin_flag engine on php_admin_flag engine on 或者,在我的服务器上对解决方案进行编辑的复制/粘贴:
php_admin_flag engine on php_admin_flag engine on (Other configuration parameters)
我已经搜索了很长时间了,我刚刚找到了一个适用于我的解决方案。 我把我的文件( processorder.php5
)放在标准的ubuntu安装目录/var/www
中。 我以为这是php看的地方。 但是对于html(或者可能被认为是相同的php文件),它在/var/www/html
查找,即/var/www
的html
子目录。
当我将文件移动到目录时,它工作了。 我很怀疑,因为我认为我在任何地方都没有看到过这种情况
权限问题也可能导致这种奇怪的行为
chmod -R u=rwX,go=rX my_publishing_directory
将摆脱权限问题(文件644和目录755)