VHOST on Debian 9 not working

April 26, 2018 925 views
Apache Debian

Hi everybody,

I've got a Debian 9 wth ISPConfig 3 installed and the vhost doesn't seem to work, my droplet's address is tikiwebdev.tk, when I type tikiwebdev.tk I get forwarded to the correct web folder, but I have another domain: alexdownunder.tk, when I type this address I get forwarded to tikiwebdev's web folder.
I've got another web server with ISPConfig installed and I don't have that problem.

I've created the domain on the Digital Ocean admin panel, redirecting to the IP of the server (for both domains).
Here is the result of the apache2ctl -S command:

VirtualHost configuration:
167.99.225.23:80       tikiwebdev.tk (/etc/apache2/sites-enabled/100-tikiwebdev.tk.vhost:7)
167.99.225.23:443      tikiwebdev.tk (/etc/apache2/sites-enabled/100-tikiwebdev.tk.vhost:92)
*:8081                 tikiwebdev.tk (/etc/apache2/sites-enabled/000-apps.vhost:9)
*:8080                 tikiwebdev.tk (/etc/apache2/sites-enabled/000-ispconfig.vhost:9)
*:80                   is a NameVirtualHost
         default server tikiwebdev.tk (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost tikiwebdev.tk (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost alexdownunder.tk (/etc/apache2/sites-enabled/100-alexdownunder.tk.vhost:7)
                 alias www.alexdownunder.tk
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex fcgid-pipe: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex authdigest-client: using_defaults
Mutex fcgid-proctbl: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33
Group: name="www-data" id=33

I cannot seem to understand what is wrong as the vhost conf files between the two ISPConfig servers are identical but it works on one but not the other.

Thank you!

2 Answers

First off, I'm not sure the code above is formatted well.

For a virtual host to serve docs from another directory, you'll need to declare a DocumentRoot in the virtual host.

<VirtualHost *:80>
    DocumentRoot "/var/www/html/domain1"
    ServerName domain1.com
    ServerAlias www.domain1.com
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "/var/www/html/domain2"
    ServerName domain2.com
    ServerAlias www.domain2.com
</VirtualHost>
  • Thanks for the reply.

    My bad, I forgot to add the vhost conf files, here they are:

    <Directory /var/www/tikiwebdev.tk>
            AllowOverride None
                    Require all denied
            </Directory>
    
    <VirtualHost *:80>
    
            DocumentRoot /var/www/tikiwebdev.tk/web
    
            ServerName tikiwebdev.tk
            ServerAdmin webmaster@tikiwebdev.tk
    
            ErrorLog /var/log/ispconfig/httpd/tikiwebdev.tk/error.log
    
            Alias /error/ "/var/www/tikiwebdev.tk/web/error/"
            ErrorDocument 400 /error/400.html
            ErrorDocument 401 /error/401.html
            ErrorDocument 403 /error/403.html
            ErrorDocument 404 /error/404.html
            ErrorDocument 405 /error/405.html
            ErrorDocument 500 /error/500.html
            ErrorDocument 502 /error/502.html
            ErrorDocument 503 /error/503.html
    
            <IfModule mod_ssl.c>
            </IfModule>
    
            <Directory /var/www/tikiwebdev.tk/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +FollowSymLinks
                    AllowOverride All
                                    Require all granted
                                    <Files ~ '.php[s3-6]{0,1}$'>
                                                    Require all denied
                                            </Files>
            </Directory>
            <Directory /var/www/clients/client0/web1/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +FollowSymLinks
                    AllowOverride All
                                    Require all granted
                                    <Files ~ '.php[s3-6]{0,1}$'>
                                            Require all denied
                                        </Files>
            </Directory>
    
    
    
    
            # suexec enabled
            <IfModule mod_suexec.c>
                SuexecUserGroup web1 client0
            </IfModule>
    
    
    
            # add support for apache mpm_itk
            <IfModule mpm_itk_module>
                AssignUserId web1 client0
            </IfModule>
    
            <IfModule mod_dav_fs.c>
            # Do not execute PHP files in webdav directory
                <Directory /var/www/clients/client0/web1/webdav>
                    <ifModule mod_security2.c>
                        SecRuleRemoveById 960015
                        SecRuleRemoveById 960032
                    </ifModule>
                    <FilesMatch "\.ph(p3?|tml)$">
                        SetHandler None
                    </FilesMatch>
                </Directory>
                DavLockDB /var/www/clients/client0/web1/tmp/DavLock
                # DO NOT REMOVE THE COMMENTS!
                # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
          # WEBDAV BEGIN
                # WEBDAV END
            </IfModule>
    
    
    
    </VirtualHost>
    
    
    <VirtualHost *:443>
    
            DocumentRoot /var/www/tikiwebdev.tk/web
    
            ServerName tikiwebdev.tk
            ServerAdmin webmaster@tikiwebdev.tk
    
            ErrorLog /var/log/ispconfig/httpd/tikiwebdev.tk/error.log
    
            Alias /error/ "/var/www/tikiwebdev.tk/web/error/"
            ErrorDocument 400 /error/400.html
            ErrorDocument 401 /error/401.html
            ErrorDocument 403 /error/403.html
            ErrorDocument 404 /error/404.html
            ErrorDocument 405 /error/405.html
            ErrorDocument 500 /error/500.html
            ErrorDocument 502 /error/502.html
            ErrorDocument 503 /error/503.html
    
            <IfModule mod_ssl.c>
            SSLEngine on
            SSLProtocol All -SSLv2 -SSLv3
            # SSLCipherSuite          ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS
            SSLHonorCipherOrder     on
            # <IfModule mod_headers.c>
            # Header always add Strict-Transport-Security "max-age=15768000"
            # </IfModule>
            SSLCertificateFile /var/www/clients/client0/web1/ssl/tikiwebdev.tk-le.crt
            SSLCertificateKeyFile /var/www/clients/client0/web1/ssl/tikiwebdev.tk-le.key
                    SSLCertificateChainFile /var/www/clients/client0/web1/ssl/tikiwebdev.tk-le.bundle
                            SSLUseStapling on
            SSLStaplingResponderTimeout 5
            SSLStaplingReturnResponderErrors off
                    </IfModule>
    
            <Directory /var/www/tikiwebdev.tk/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +FollowSymLinks
                    AllowOverride All
                                    Require all granted
                                    <Files ~ '.php[s3-6]{0,1}$'>
                                                    Require all denied
                                            </Files>
            </Directory>
            <Directory /var/www/clients/client0/web1/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +FollowSymLinks
                    AllowOverride All
                                    Require all granted
                                    <Files ~ '.php[s3-6]{0,1}$'>
                                            Require all denied
                                        </Files>
            </Directory>
    
    
    
    
            # suexec enabled
            <IfModule mod_suexec.c>
                SuexecUserGroup web1 client0
            </IfModule>
    
    
    
            # add support for apache mpm_itk
            <IfModule mpm_itk_module>
                AssignUserId web1 client0
            </IfModule>
    
            <IfModule mod_dav_fs.c>
            # Do not execute PHP files in webdav directory
                <Directory /var/www/clients/client0/web1/webdav>
                    <ifModule mod_security2.c>
                        SecRuleRemoveById 960015
                        SecRuleRemoveById 960032
                    </ifModule>
                    <FilesMatch "\.ph(p3?|tml)$">
                        SetHandler None
                    </FilesMatch>
                </Directory>
                DavLockDB /var/www/clients/client0/web1/tmp/DavLock
                # DO NOT REMOVE THE COMMENTS!
                # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
          # WEBDAV BEGIN
                # WEBDAV END
            </IfModule>
    
    
    
    </VirtualHost>
    
    <IfModule mod_ssl.c>
            SSLStaplingCache shmcb:/var/run/ocsp(128000)
    </IfModule>
    

    And for alexdownunder.tk:

    <Directory /var/www/alexdownunder.tk>
            AllowOverride None
                    Require all denied
            </Directory>
    
    <VirtualHost *:80>
    
            DocumentRoot /var/www/clients/client0/web2/web
    
            ServerName alexdownunder.tk
            ServerAlias www.alexdownunder.tk
            ServerAdmin webmaster@alexdownunder.tk
    
            ErrorLog /var/log/ispconfig/httpd/alexdownunder.tk/error.log
    
            Alias /error/ "/var/www/alexdownunder.tk/web/error/"
            ErrorDocument 400 /error/400.html
            ErrorDocument 401 /error/401.html
            ErrorDocument 403 /error/403.html
            ErrorDocument 404 /error/404.html
            ErrorDocument 405 /error/405.html
            ErrorDocument 500 /error/500.html
            ErrorDocument 502 /error/502.html
            ErrorDocument 503 /error/503.html
    
            <IfModule mod_ssl.c>
            </IfModule>
    
            <Directory /var/www/alexdownunder.tk/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +FollowSymLinks
                    AllowOverride All
                                    Require all granted
                            </Directory>
            <Directory /var/www/clients/client0/web2/web>
                    # Clear PHP settings of this website
                    <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                            SetHandler None
                    </FilesMatch>
                    Options +FollowSymLinks
                    AllowOverride All
                                    Require all granted
                            </Directory>
    
    
    
    
            # suexec enabled
            <IfModule mod_suexec.c>
                SuexecUserGroup web2 client0
            </IfModule>
            <IfModule mod_fastcgi.c>
                    <Directory /var/www/clients/client0/web2/cgi-bin>
                                            Require all granted
                                        </Directory>
                    <Directory /var/www/alexdownunder.tk/web>
                        <FilesMatch "\.php[345]?$">
                            SetHandler php5-fcgi
                        </FilesMatch>
                    </Directory>
                    <Directory /var/www/clients/client0/web2/web>
                        <FilesMatch "\.php[345]?$">
                            SetHandler php5-fcgi
                        </FilesMatch>
                    </Directory>
                    Action php5-fcgi /php5-fcgi virtual
                    Alias /php5-fcgi /var/www/clients/client0/web2/cgi-bin/php5-fcgi-167.99.225.23-80-alexdownunder.tk
                    FastCgiExternalServer /var/www/clients/client0/web2/cgi-bin/php5-fcgi-167.99.225.23-80-alexdownunder.tk -idle-timeout 300 -socket /var/lib/php7.0-fpm/web2.sock -pass-header Authorization  -pass-header Content-Type
            </IfModule>
            <IfModule mod_proxy_fcgi.c>
                #ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ unix:///var/lib/php7.0-fpm/web2.sock|fcgi://localhost//var/www/clients/client0/web2/web/$1
                <Directory /var/www/clients/client0/web2/web>
                    <FilesMatch "\.php[345]?$">
                            SetHandler "proxy:unix:/var/lib/php7.0-fpm/web2.sock|fcgi://localhost"
                    </FilesMatch>
                </Directory>
                </IfModule>
    
    
    
            # add support for apache mpm_itk
            <IfModule mpm_itk_module>
                AssignUserId web2 client0
            </IfModule>
    
            <IfModule mod_dav_fs.c>
            # Do not execute PHP files in webdav directory
                <Directory /var/www/clients/client0/web2/webdav>
                    <ifModule mod_security2.c>
                        SecRuleRemoveById 960015
                        SecRuleRemoveById 960032
                    </ifModule>
                    <FilesMatch "\.ph(p3?|tml)$">
                        SetHandler None
                    </FilesMatch>
                </Directory>
                DavLockDB /var/www/clients/client0/web2/tmp/DavLock
                # DO NOT REMOVE THE COMMENTS!
                # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
          # WEBDAV BEGIN
                # WEBDAV END
            </IfModule>
    </VirtualHost>
    

My suggestion will be to start with something small and then add additional lines of code to identify where exactly the issue starts.

Have another answer? Share your knowledge.