我的/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>
但是在通过 userdir 访问网站时 php 不起作用。 www.example.com/~admin 当我通过域访问时,它可以工作。我已经安装了 zPanel
服务器版本:Apache/2.4.18 (Ubuntu)
在我的/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>                                                        
我想现在你知道该怎么做了。
尝试以下操作:
mod_userdir已启用 ( a2enmod userdir)。和dirs 具有正确的读取权限$HOME。public_html
sudo -Hu SOMEUSER sh -c 'chmod 755 $HOME $HOME/public_html'
确保php_admin_value engine是On.
sudo vim /etc/apache2/mods-enabled/php*.conf
然后找到包含的行php_admin_flag并将其更改为:
php_admin_flag engine On
这是因为 Apache 2 的用户目录默认禁用 PHP。
在您的特定情况下,您必须取消注释以下行:
<IfModule mod_userdir.c>
    <Directory /var/zpanel/hostdata/*/public_html/*>
        php_admin_value engine On
    </Directory>
</IfModule>
| 归档时间: | 
 | 
| 查看次数: | 7531 次 | 
| 最近记录: |