What ServerAlias for my Subdomain?

Sorry again for this basic questions but i see that many developers have not clear ideas :)

This is my subdomain: subdomain.example.com that want to use for a very simple rail app.

This is my .conf file:

# domain: subdomain.example.com
# public: /var/www/subdomain.example.com/public_html/

 <virtualhost *:80=""># Admin email, Server Name (domain name), and any aliases
  ServerAdmin webmaster@example.com
  ServerName  www.subdomain.example.com
  ServerAlias subdomain.example.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/subdomain.example.com/public_html

  <directory var="" www="" subdomain.example.com="" public_html=""># Log file locations
  LogLevel warn
  ErrorLog  /var/www/subdomain.example.com/log/error.log
  CustomLog /var/www/subdomain.example.com/log/access.log combined</directory></virtualhost> 

The question is: the ServerAlias must be "subdomain.example.com" OR "example.com"?

And please confirm, this setting is independent if i manage my domains DNS from "Linode DNS Manager" OR from my "Registrar DNS Panel"?

2 Replies

so why you use "www.subdomain.example.com" ?

if you want to create subdomain it's better just create subdomain.example.com, it think if you use www.subdomain.example.com it's subdomain in subdomain.

serveralias is just optional you just need ServerName subdomain.example.com if you want to create subdomain.example.com

so the conf is:

# Admin email, Server Name (domain name), and any aliases

ServerAdmin webmaster@example.com

ServerName subdomain.example.com

Index file and Document Root (where the public files are located)

DirectoryIndex index.html index.php

DocumentRoot /var/www/subdomain.example.com/public_html

# Log file locations

LogLevel warn

ErrorLog /var/www/subdomain.example.com/log/error.log

CustomLog /var/www/subdomain.example.com/log/access.log combined

That's actually how I would do it.

@jessicarey:

so why you use "www.subdomain.example.com" ?

if you want to create subdomain it's better just create subdomain.example.com, it think if you use http://www.subdomain.example.com it's subdomain in subdomain.

serveralias is just optional you just need ServerName subdomain.example.com if you want to create subdomain.example.com

so the conf is:

# Admin email, Server Name (domain name), and any aliases

ServerAdmin webmaster@example.com

ServerName subdomain.example.com

Index file and Document Root (where the public files are located)

DirectoryIndex index.html index.php

DocumentRoot /var/www/subdomain.example.com/public_html

# Log file locations

LogLevel warn

ErrorLog /var/www/subdomain.example.com/log/error.log

CustomLog /var/www/subdomain.example.com/log/access.log combined

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct