userdir中的PHP无法正常工作 [英] PHP in userdir not working

查看:71
本文介绍了userdir中的PHP无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的/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

But php not working when in accessing web site via userdir. www.example.com/~admin When i access via domain then it works. I have zPanel installed

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

Server version: 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>                                                        

我认为您现在知道该怎么做.

I think now you know what to do.

这篇关于userdir中的PHP无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆