浏览器下载来自Apache Web服务器的PHP文件
我有一个Apache Web服务器。比方说,这台服务器的域名的 example.com 的
I have an apache web server. Let's say this server's domain is example.com.
在我访问的 example.com 的,那么的index.php
文件正确显示在浏览器。
When I access example.com, then the index.php
file is correctly displayed in the browser.
然而,当我访问例如的 example.com/~user 的,然后的的index.php
文件 /home/user/public_html/index.php
文件下载,而不是显示。
However, when I access e.g. example.com/~user, then the index.php
file of /home/user/public_html/index.php
file is downloaded rather than displayed.
我该如何解决这个问题?我换expose_php =关
在的php.ini
,但一切都没有改变。
How do I fix this problem? I changed "expose_php = Off"
in php.ini
, but nothing has changed.
如果你是在Debian / Ubuntu的看看这个文件 /etc/apache2/mods-available/php5.conf
If you are on Debian/Ubuntu take a look at this file /etc/apache2/mods-available/php5.conf
矿看起来像这样,你可以看到,我不得不发表评论一些行让PHP在用户目录工作
mine looks like this and you can see I had to comment some line to get PHP working in the user dir
<IfModule mod_php5.c>
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
#<IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_value engine Off
# </Directory>
#</IfModule>
</IfModule>
请注意,编辑的文件后,你将不得不重新启动Apache以使修改生效,重新启动基于Debian的系统上的Apache的命令是: /etc/init.d/apache2重启
Please note that after editing the file you would have to restart apache for the modifications to take effect, the command to restart apache on a debian based system is: /etc/init.d/apache2 restart