Can't get subdomain to work via virtual hosts - Ubuntu

June 8, 2014 2.4k views
Hey all, I'm new to working with webservers manually and I am trying to setup a subdomain via apache's virtual hosts but I can't get it to work. This is the tutorial I followed https://www.digitalo...buntu-12-04-lts Here is some initial info: I have my website running just fine with the main domain http://shayConcepts.com and it's running from /home/scDev/public_html I'm trying to create a test sub domain, ftest.shayconcepts.com. Located at /home/scDev/ftest My domain is not through digital ocean And here's exactly what I did sudo chown -R $USER:$USER /home/scDev/ftest (I also tried sudo chown -R www-data:www-data /home/scDev/ftest sudo chmod -R 755 /home/scDev/ftest created an index.html in ftest cd /etc/apache2/sites-available sudo cp ./default.conf ./xftest.conf Here's the contents of xftest.conf # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin andrewshay@shayconcepts.com ServerName ftest.shayconcepts.com DocumentRoot /home/scDev/ftest Options FollowSymLinks AllowOverride None AllowOverride None Order allow,deny Allow from all Require all granted # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf sudo a2ensite xftest.conf sudo service apache2 reload sudo service apache2 restart
4 Answers
It's missing the html from the file, here is my new attempt, the { are greater than, less than signs

{VirtualHost *:80}
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin andrewshay@shayconcepts.com
ServerName ftest.shayconcepts.com
DocumentRoot /home/scDev/ftest
{Directory /}
Options FollowSymLinks
AllowOverride None
{/Directory}
{Directory /home/scDev/ftest/}
AllowOverride None
Order allow,deny
Allow from all
Require all granted
{/Directory}

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
{/VirtualHost}
Did you add an ftest record pointing to your server under the DNS settings of shayconcepts.com?
I did not. Do I do this under DO or my domain host?
I assume you changed the nameservers on your domain host for shayconcepts.com to point to DO, and then in the DNS in DO told it to use shayconcepts.com for your VM. If this is the case in the DNS section in DO you will add a record for ftest.
Have another answer? Share your knowledge.