Small blog about system administration.

Adding a subdomain pointing to custom folder (for example, inside webroot)

Usually, I work with CPanel.
But some time ago my friend asked me to move his website to a server with Plesk installed by default.
Website required domain sub.domain.com to point to a folder inside main site webroot.
I surprizingly found, that with Plesk 9 it is impossible (it was ok with old versions where Plesk allowed to choose subdomain destination folder). I had to find a way to overcome that.

It is easy. But you need to be root for that.

Open /var/www/vhosts/domain.com/subdomains/sub/conf/vhost.conf in editor.

Add to it the following contents (for sub.domain.com):

DocumentRoot /var/www/vhosts/domain.com/httpdocs/sub 
<Directory /var/www/vhosts/domain.com/httpdocs/sub> 
     <IfModule sapi_apache2.c> 
        php_admin_flag engine on 
        php_admin_flag safe_mode off 
        php_admin_value open_basedir "/var/www/vhosts/domain.com/httpdocs:/tmp" 
     </IfModule> 
     <IfModule mod_php5.c> 
        php_admin_flag engine on 
        php_admin_flag safe_mode off 
        php_admin_value open_basedir "/var/www/vhosts/domain.com/httpdocs:/tmp" 
     </IfModule> 
 Options -Includes -ExecCGI 
</Directory>

After that you need to reconfigure Plesk by using command

# /usr/local/psa/admin/bin/websrvmng -a

1 comment :

Post a Comment