Trouble setting up subdomain with Apache2 on Ubuntu 12.04
I have the following situation:
1. My domain name is managed by a registrar in my country. The only thing I use them for is IP Forwarding. So I logged into their control panel and created a subdomain.domain.com and then entered the IP number of my Linode instance in the A-Record.
2. Then on my Linode instance, I created a new subdomain in /etc/apache2/subdomain.domain.com by creating a new VirtualHost. The document root is located at ~/public/subdomain.domain.com/public
Problem:
When I try to call up subdomain.domain.com in the browser I get a page that says:
> Forbidden
You don't have permission to access / on this server.
However, this page does not appear to be on my Linode instance! It appears to be a page on some server belonging to my registrar (I do not use their hosting, only IP Forwarding).
Any idea what I could be doing wrong?
Thanks.
13 Replies
$ ls -lh ~/public/subdomain.domain.com/public
That will show a listing of files, as well as permissions (represented by the letters r(ead), w(rite), and x(ecute), and user/group ownership.
Either the user or group (or both) should be set to the user that Apache uses, and that user or group needs (at a minimum) read and execute permission for all directories it needs access to, and read permissions for all files it needs.
mope@ubuntu:~/public$ ls -lh subdomain.domain.com
total 12K
drwxrwxr-x 2 mope mope 4.0K Jul 6 00:01 backup
drwxrwxr-x 2 mope mope 4.0K Jul 6 00:07 logs
drwxrwxr-x 12 mope mope 4.0K Jul 6 23:59 public
What are the permissions of all the parent directories?
Is DocumentRoot literally ~/public/subdomain.domain.com/public? ~ is short hand for the current user's home directory, and your webserver will be running as a user that is not "mope".
Also, please don't redact, it helps us cross-check a few things, including that your a record is set properly.
@bacon:
What makes you sure that the page returned isn't on your server?
Because the page that is appearing contains an iFrame with an unknown (to me) source IP.
@bacon:
What are the permissions of all the parent directories?
mope@ubuntu:~$ ls -lh public
total 8.0K
drwxrwxr-x 5 mope mope 4.0K Jun 9 21:51 domain.com
drwxrwxr-x 5 mope mope 4.0K Jul 6 11:23 subdomain.domain.com
@bacon:
Is DocumentRoot literally ~/public/subdomain.domain.com/public? ~ is short hand for the current user's home directory, and your webserver will be running as a user that is not "mope".
I am not using the short hand in my VirtualHost file, instead I am using this: /home/mope/public/subdomain.domain.com/public
(But mind you I have this very same set up for domain.com and everything is working fine)
What do your logs say?
@Main Street James:
I realize this is a stupid question, but since everything seems to be configured the same and both sites should be displaying: did you restart the apache service?
Yup restarted several times since making the changes
@Main Street James:
What do your logs say?
I will have a look at the logs later today.
One strange thing I just noticed is that if I try to visit subdomain.domain.com from the office I still get the 403 page, but without the iframe page I see at home?? No idea what that means.
Because looking at some examples online, I see for example this setup: ServerName: subdomain.domain.com and ServerAlias
Could this be issue? (Can't check it right now).
So what exactly is the problem again???
@vonskippy:
When I click on your links (
http://www.domain.com and subdomain.domain.com) both of them resolve to a web page.So what exactly is the problem again???
These are obviously examples.
Under domain.com I have an .htaccess file forcing HTTPS.
Under subdomain.domain.com I have a Piwik installation and that doesn't seem to like this and was throwing a 403.
I disabled the .htaccess for now and I can access subdomain.domain.com
@Mope:
These are obviously examples.
No, they're obvious TIME WASTERS.
Domain names by their nature are PUBLIC, so hiding them makes zero sense.