浏览器从 apache 网络服务器下载 php 文件 [英] browser downloads php file from apache web server
问题描述
我有一个 apache 网络服务器.假设此服务器的域是 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,则下载/home/user/public_html/index.php
文件的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.
我该如何解决这个问题?我在 php.ini
中更改了 "expose_php = Off"
,但没有任何变化.
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 restart
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
这篇关于浏览器从 apache 网络服务器下载 php 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!