Adding a subdomain on Apache2 (Ubuntu 12.04)

February 23, 2015 1.5k views

Hello. I'm trying to add a subdomain "dev" to my site which is running on Ubuntu 12.04x64
I had spent a few days to do this, but without any result. Only "This webpage is not available." error.

Here is a zone file showed in https://cloud.digitalocean.com/domains/ubium.ru

$ORIGIN ubium.ru.
$TTL 1800
ubium.ru. IN SOA ns1.digitalocean.com. hostmaster.ubium.ru. 1424702134 10800 3600 604800 1800
ubium.ru. 1800 IN NS ns1.digitalocean.com.
ubium.ru. 1800 IN NS ns2.digitalocean.com.
ubium.ru. 1800 IN NS ns3.digitalocean.com.
ubium.ru. 1800 IN A 188.166.63.44
dev.ubium.ru. 1800 IN A 188.166.63.44
*.dev.ubium.ru. 1800 IN CNAME dev.ubium.ru.
*.ubium.ru. 1800 IN CNAME ubium.ru.

Here is apache2.conf

<VirtualHost 188.226.173.208:8080>

    ServerName ubium.ru
    ServerAlias www.ubium.ru
    ServerAdmin info@ubium.ru
    DocumentRoot /home/ubium/web/ubium.ru/public_html
    ScriptAlias /cgi-bin/ /home/ubium/web/ubium.ru/cgi-bin/
    Alias /vstats/ /home/ubium/web/ubium.ru/stats/
    Alias /error/ /home/ubium/web/ubium.ru/document_errors/
    #SuexecUserGroup ubium ubium
    CustomLog /var/log/apache2/domains/ubium.ru.bytes bytes
    CustomLog /var/log/apache2/domains/ubium.ru.log combined
    ErrorLog /var/log/apache2/domains/ubium.ru.error.log
    <Directory /home/ubium/web/ubium.ru/public_html>
        AllowOverride All
        Options +Includes -Indexes +ExecCGI
    </Directory>
    <Directory /home/ubium/web/ubium.ru/stats>
        AllowOverride All
    </Directory>

    <IfModule mod_ruid2.c>
        RMode config
        RUidGid ubium ubium
        RGroups www-data
    </IfModule>
    <IfModule itk.c>
        AssignUserID ubium ubium
    </IfModule>

    Include /home/ubium/conf/web/apache2.ubium.ru.conf*

</VirtualHost>


<VirtualHost 188.226.173.208:8080>

    ServerName dev.ubium.ru
    ServerAlias www.dev.ubium.ru
    ServerAdmin info@ubium.ru
    DocumentRoot /home/ubium/web/ubium.ru/public_html
    ScriptAlias /cgi-bin/ /home/ubium/web/ubium.ru/cgi-bin/
    Alias /vstats/ /home/ubium/web/ubium.ru/stats/
    Alias /error/ /home/ubium/web/ubium.ru/document_errors/
    #SuexecUserGroup ubium ubium
    CustomLog /var/log/apache2/domains/ubium.ru.bytes bytes
    CustomLog /var/log/apache2/domains/ubium.ru.log combined
    ErrorLog /var/log/apache2/domains/ubium.ru.error.log
    <Directory /home/ubium/web/ubium.ru/public_html>
        AllowOverride All
        Options +Includes -Indexes +ExecCGI
    </Directory>
    <Directory /home/ubium/web/ubium.ru/stats>
        AllowOverride All
    </Directory>

    <IfModule mod_ruid2.c>
        RMode config
        RUidGid ubium ubium
        RGroups www-data
    </IfModule>
    <IfModule itk.c>
        AssignUserID ubium ubium
    </IfModule>

    Include /home/ubium/conf/web/apache2.ubium.ru.conf*

</VirtualHost>

<VirtualHost 188.166.63.44:8080>

    ServerName dev.ubium.ru
    ServerAlias www.dev.ubium.ru
    ServerAdmin info@ubium.ru
    DocumentRoot /home/ubium/web/ubium.ru/public_html
    ScriptAlias /cgi-bin/ /home/ubium/web/ubium.ru/cgi-bin/
    Alias /vstats/ /home/ubium/web/ubium.ru/stats/
    Alias /error/ /home/ubium/web/ubium.ru/document_errors/
    #SuexecUserGroup ubium ubium
    CustomLog /var/log/apache2/domains/ubium.ru.bytes bytes
    CustomLog /var/log/apache2/domains/ubium.ru.log combined
    ErrorLog /var/log/apache2/domains/ubium.ru.error.log
    <Directory /home/ubium/web/ubium.ru/public_html>
        AllowOverride All
        Options +Includes -Indexes +ExecCGI
    </Directory>
    <Directory /home/ubium/web/ubium.ru/stats>
        AllowOverride All
    </Directory>

    <IfModule mod_ruid2.c>
        RMode config
        RUidGid ubium ubium
        RGroups www-data
    </IfModule>
    <IfModule itk.c>
        AssignUserID ubium ubium
    </IfModule>

    Include /home/ubium/conf/web/apache2.ubium.ru.conf*

</VirtualHost>

And here is hginx.conf

server {
    listen      188.226.173.208:80;
    server_name ubium.ru www.ubium.ru;
    error_log  /var/log/apache2/domains/ubium.ru.error.log error;

    location / {
        proxy_pass      http://188.226.173.208:8080;
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|css|zip|tgz|gz|rar|bz2|exe|pdf|doc|xls|ppt|txt|odt|ods|odp|odf|tar|bmp|rtf|js|mp3|avi|mpeg|flv|html|htm)$ {
            root           /home/ubium/web/ubium.ru/public_html;
            access_log     /var/log/apache2/domains/ubium.ru.log combined;
            access_log     /var/log/apache2/domains/ubium.ru.bytes bytes;
            expires        max;
            try_files      $uri @fallback;
        }
    }

    location /error/ {
        alias   /home/ubium/web/ubium.ru/document_errors/;
    }

    location @fallback {
        proxy_pass      http://188.226.173.208:8080;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include /home/ubium/conf/web/nginx.ubium.ru.conf*;
}

Please, help me, if it is possible.

2 Answers

A quick lookup of your domain name is showing that you have not pointed it to our DNS servers so the records you have created for it are not yet being used:

domain:        UBIUM.RU
nserver:       dns1.yandex.net.
nserver:       dns2.yandex.net.

You'll need to point your domain to our nameservers (listed below) with your registrar:

ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com

Hello. Thank you for your advise:) But now i have another problem.
My domain http://ubium.ru/ is always shows apache default page and any VirtualHost changes had no result. I tried to configure it like in this tutorial
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts
May be this domain did not connected to my droplet ?

by Etel Sverdlov
This tutorial shows you how to set up a new directory, how to grant the correct permissions, how to add content to a new page, how to turn on virtual hosting, and how to, if needed, set up local hosts. Virtual Hosts are used to run more than one domain off of a single IP address and allows you to run multiple sites off of a single DigitalOcean droplet. This tutorial describes how to set up virtual hosts with Apache.
Have another answer? Share your knowledge.