用户目录中的 PHP 不起作用

Dam*_*vic 5 php apache ubuntu

我的/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>
Run Code Online (Sandbox Code Playgroud)

和文件/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>
Run Code Online (Sandbox Code Playgroud)

但是在通过 userdir 访问网站时 php 不起作用。 www.example.com/~admin 当我通过域访问时,它可以工作。我已经安装了 zPanel

服务器版本:Apache/2.4.18 (Ubuntu)

Shi*_*dim 5

在我的/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>                                                        
Run Code Online (Sandbox Code Playgroud)

我想现在你知道该怎么做了。


ken*_*orb 2

尝试以下操作:


在您的特定情况下,您必须取消注释以下行:

<IfModule mod_userdir.c>
    <Directory /var/zpanel/hostdata/*/public_html/*>
        php_admin_value engine On
    </Directory>
</IfModule>
Run Code Online (Sandbox Code Playgroud)