Trouble setting up subdomain with Apache2 on Ubuntu 12.04

Hi there,

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

Chances are it is pointing to your Linode and apache is just telling you it doesn't have permission to access it. Can you show the output of:

$ 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.

Here is the output:

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 makes you sure that the page returned isn't on your server?

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)

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?

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.

One other thing I just realized, in my VirtualHost file for my subdomain I have for both ServerName and ServerAlias: subdomain.domain.com

Because looking at some examples online, I see for example this setup: ServerName: subdomain.domain.com and ServerAlias www.domain.com

Could this be issue? (Can't check it right now).

When I click on your links (www.domain.com and subdomain.domain.com) both of them resolve to a web page.

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.

When I view subdomain.domain.com from my iPhone it works and I can see the site hosted on the sub domain. But when I view it from my computer, I get a 403??

I finally figured it out.

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

In the future, please don't redact information - it impedes us helping you.

@Mope:

These are obviously examples.
No, they're obvious TIME WASTERS.

Domain names by their nature are PUBLIC, so hiding them makes zero sense.

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