I'm trying to set up a subdomain with Apache2 on my Ubuntu droplet, I've followed this tutorial to the T but every time I navigate to my subdomain, I get the default apache landing page.
So I've set up separate conf files for both my main and sub domains,
/etc/apache2/sites-available/mainsite.conf:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/mainsite/public_html
ServerName www.example.com
ServerAlias example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/apache2/sites-available/sub.conf:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/submainsite/public_html
ServerName sub.example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What am I doing wrong? I don't have much server side experience, so please pardon my ignorance on the matter.
EDIT:
Both sites are linked, I did run a2ensite
.
When running apachectl -S
I get:
default server sub.example.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost sub.example.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost sub.example.com (/etc/apache2/sites-enabled/sub.conf:1)
port 80 namevhost www.example.com (/etc/apache2/sites-enabled/mainsite.conf:1)
alias example.com
apachectl configtest
; did you place an IndexDocument in the DocumentRoot of the subdomain; which virtual hosts are shown byapachectl -S
? And IIRC writing to the same log files from within two different VirtualHost entries is a no no./etc/apache2/sites-enabled
i.e. did you runa2ensite sub
?