我的/etc/apache2/mods-enabled/userdir.conf文件如下所示:
<IfModule mod_userdir.c>
UserDir /var/zpanel/hostdata/*/public_html/
UserDir disabled root
<Directory /var/zpanel/hostdata/*/public_html/*>
AllowOverride All
Options MultiViews Indexes SymLinksIfOwnerMatch
<Limit GET POST OPTIONS>
# Apache <= 2.2:
Order allow,deny
Allow from all
# Apache >= 2.4:
# Require all granted
</Limit>
<LimitExcept GET POST OPTIONS>
# Apache <= 2.2:
Order deny,allow
Deny from all
# Apache >= 2.4:
#Require all denied
</LimitExcept>
</Directory>
</IfModule>
和文件/etc/apache2/mods-enabled/php5.conf
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
SetHandler application/x-httpd-php-source
# Deny access to raw php sources by default
# To re-enable it's recommended to enable access to the files
# only in specific virtual host or directory
Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[345]?|t|tml|ps)$">
Require all denied
</FilesMatch>
# Running PHP scripts in user directories is disabled by default
#
# 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 /var/zpanel/hostdata/*/public_html/*>
# php_admin_value engine On
# </Directory>
#</IfModule>
但是php在通过userdir访问网站时不起作用。www.example.com/~admin当我通过域访问时,它就可以工作了。我安装了zPanel
服务端版本: Apache/2.4.18 (Ubuntu)
发布于 2018-06-18 04:12:52
在我的/etc/apache2/mods-available/php7.0.conf
中,我有这个部分
# Running PHP scripts in user directories is disabled by default
#
# 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_flag engine Off
</Directory>
</IfModule>
我想现在你知道该怎么做了。
发布于 2017-04-01 21:58:00
尝试以下操作:
mod_userdir
已启用,并且$HOME
和public_html
目录具有正确的读取权限。sudo $HOME/public_html'
php_admin_value engine
is On
.sudo vim /etc/apache2/mods-enabled/php*.conf
然后找到包含php_admin_flag
的行,并将其更改为:
php_admin_flag引擎开启
这是因为对于Apache2的用户目录,默认情况下禁用PHP。
在您的特定情况下,您必须取消对以下行的注释:
<IfModule mod_userdir.c>
<Directory /var/zpanel/hostdata/*/public_html/*>
php_admin_value engine On
</Directory>
</IfModule>
发布于 2020-11-30 14:30:55
正如@kenorb所提到的,这是因为PHP在Apache2的userdirs中默认是禁用的。
但是,不是在/etc/apache2/mods-enabled/php*.conf
中将php_admin_value engine
更改为On
,而是在.conf
文件本身中建议注释掉从<IfModule>
到</IfModule>
的行,以便.htaccess
可以单独处理该设置。具体实现方法如下所示:
#<IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_flag engine Off
# </Directory>
#</IfModule>
https://stackoverflow.com/questions/35928184
复制相似问题