My /etc/apache2/mods-enabled/userdir.conf file looks like:
<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>
And file /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>
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
Server version: Apache/2.4.18 (Ubuntu)
In my /etc/apache2/mods-available/php7.0.conf
I have this section
# 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.
Try the following actions:
mod_userdir
is enabled (a2enmod userdir
).The $HOME
and public_html
dirs have the right read permissions.
sudo -Hu SOMEUSER sh -c 'chmod 755 $HOME $HOME/public_html'
Make sure php_admin_value engine
is On
.
sudo vim /etc/apache2/mods-enabled/php*.conf
Then find the line containing php_admin_flag
and change it to:
php_admin_flag engine On
This is due that PHP is disabled by default for user dirs for Apache 2.
In your particular case, you've to uncomment the following lines:
<IfModule mod_userdir.c>
<Directory /var/zpanel/hostdata/*/public_html/*>
php_admin_value engine On
</Directory>
</IfModule>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With