Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Re: Creating subdomains
PostPosted: Mon Apr 01, 2013 4:08 am 
Offline
Senior Member

Joined: Fri Feb 17, 2012 8:20 pm
Posts: 365
Could you also post:
Quote:
and the output of the config files there (cat /etc/apache2/sites-enabled/*)


The dash doesn't matter :)

I am on IRC (#linode), so you can poke me (Kami) there or someone else. It's probably best to ask in the chat in general, I don't do much with Apache, just nginx :)


Top
   
 Post subject: Re: Creating subdomains
PostPosted: Mon Apr 01, 2013 10:04 am 
Offline
Senior Member
User avatar

Joined: Tue Nov 24, 2009 1:59 pm
Posts: 362
Quote:
Code:
lrwxrwxrwx 1 root root 56 Mar 30 10:29 sub-mydomain.com -> /etc/apache2/sites-available/sub.mydomain.com

This is crazy, the names don't match.
Have you made this symlink manually?

To put all info in one place:

0. You need a DNS entry for the domain and/or subdomain pointing to the server.

1. You should edit only the "real files" in /etc/apache2/sites-available/

2. To "activate" a site, you run
Code:
a2ensite file.name.here && invoke-rc.d apache2 reload
which creates a symlink in the sites-enabled directory and tells Apache to re-read config files.

3. To deactivate, similarly use
Code:
a2dissite file.name.here && invoke-rc.d apache2 reload
which removes the symlink and tells Apache to re-read config.

4. A file in /etc/apache2/sites-available can have any name (using the domain name it is for is a good idea though.)

5. It should look like that,in its simplest form:

Code:
<VirtualHost *:80>
    ServerName sub.example.com
    DocumentRoot /path/to/files/for/the/site
</VirtualHost>


You should not put the domain name on the VirtualHost line in most cases.
Just the ServerName line.

Of course it can have a lot other entries, setting up redirects, scripting, and stuff. We can share some examples if you wish.

6. If your server is accessed by a (sub)domain name for which you do not have an explicit sites-enabled file, it'll show the first site that was configured.
The sites files are loaded in alphabetical order.
So, you should create a sites file for a placeholder (or redirect) site that should be displayed in cases like accessing your server by IP (http://1.2.3.4/), name it like 000default or ___default or similar, and enable it.

_________________
rsk, providing useless advice on the Internet since 2005.


Top
   
 Post subject: Re: Creating subdomains
PostPosted: Mon Apr 01, 2013 12:58 pm 
Offline
Senior Newbie

Joined: Thu Mar 28, 2013 9:33 pm
Posts: 12
Nuvini wrote:
Could you also post:
Quote:
and the output of the config files there (cat /etc/apache2/sites-enabled/*)


The dash doesn't matter :)

I am on IRC (#linode), so you can poke me (Kami) there or someone else. It's probably best to ask in the chat in general, I don't do much with Apache, just nginx :)


Running "cat /etc/apache2/sites-enabled/*" gave me the output:

root@testosterone:~# cat /etc/apache2/sites-enabled/*
# domain: mydomain.com
# public: /home/user/public/mydomain.com/

<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin webmaster@mydomain.com
ServerName www.mydomain.com
ServerAlias mydomain.com

# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/user/public/mydomain.com/public

# Log file locations
LogLevel warn
ErrorLog /home/user/public/mydomain.com/log/error.log
CustomLog /home/user/public/mydomain.com/log/access.log combined
</VirtualHost>
# domain: sub.mydomain.com
# public: /home/user/public/sub.mydomain.com/

<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin webmaster@mydomain.com
ServerName sub.mydomain.com
ServerAlias sub.mydomain.com

# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/user/public/sub.mydomain.com/public

# Log file locations
LogLevel warn
ErrorLog /home/user/public/sub.mydomain.com/log/error.log
CustomLog /home/user/public/sub.mydomain.com/log/access.log combined
</VirtualHost>


Top
   
 Post subject: Re: Creating subdomains
PostPosted: Mon Apr 01, 2013 3:31 pm 
Offline
Senior Newbie

Joined: Thu Mar 28, 2013 9:33 pm
Posts: 12
thanks Rsk.

I messed around a little, im learning but now neither my main domain or sub domain works. I tried re enabling them and im still getting erros.

Im in the IRC chat now, its empty.


Top
   
 Post subject: Re: Creating subdomains
PostPosted: Mon Apr 01, 2013 3:33 pm 
Offline
Senior Newbie

Joined: Thu Mar 28, 2013 9:33 pm
Posts: 12
rsk wrote:
Quote:
Code:
lrwxrwxrwx 1 root root 56 Mar 30 10:29 sub-mydomain.com -> /etc/apache2/sites-available/sub.mydomain.com

This is crazy, the names don't match.
Have you made this symlink manually?


nope. although I may have created the vhost wrong and enabling that site created the false symlink


Top
   
 Post subject: Re: Creating subdomains
PostPosted: Mon Apr 01, 2013 4:00 pm 
Offline
Senior Member

Joined: Fri Feb 17, 2012 8:20 pm
Posts: 365
the450man wrote:
thanks Rsk.

I messed around a little, im learning but now neither my main domain or sub domain works. I tried re enabling them and im still getting erros.

Im in the IRC chat now, its empty.



You must be in the wrong channel. There's a lot of people. http://chat.linode.com/cgi-bin/irc/irc.cgi should get you to the right place.


Top
   
 Post subject: Re: Creating subdomains
PostPosted: Mon Apr 01, 2013 5:18 pm 
Offline
Senior Newbie

Joined: Thu Mar 28, 2013 9:33 pm
Posts: 12
Glad to say my problem has been solved.

apache was not running :0


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group