How do I have multiple sites enabled in public_html
Hi there,
I am new to the self managed part so bear with me :)
I have in my /var/www/html/public_html/
two directories, say /one/ and /two/
I have conf files for both in /etc/apache2/sites-available/
and I have enabled them, both so they are in sites-enabled.
I have also restarted apache after this.
I directed the subdomain I made for /two
to point to my IP here, and it is showing the site files for the /one/
site I have up. Anything common I can check that I may have messed up?
Do the xxxxx.conf
file names need to match anything?
Thank you.
9 Replies
✓ Best Answer
There's something else at work here. Your symptoms don't have anything to do with the fact that you have multiple site located in public_html…
FWIW, you can put document roots anywhere in the file system. That's the purpose of the DocumentRoot directory. I tend to put them (and logs) outside the directory hierarchy where the web server configuration resides (a habit I picked up in the early days of the web when my site content was all on NFS volumes).
I'm pretty sure your issue is related to your…ummm…unorthodox DNS configuration.
Are DOMAIN_ON_LINODE_NAMESERVERS.com and DOMAIN_HOSTED_ELSEWHERE.com the same domain name?
-- sw
You need to make sure that EVERY file/directory that the web server is to read is OWNED by wwwroot:wwwroot and is readable (-rw-r--r--) by wwwroot:wwwroot The DIRECTORIES should be world-executable (-rwxr-xr-x).
Do the
xxxxx.conf
file names need to match anything?
No.
-- sw
Thanks,
I have set the permissions the same as my other one and restarted apache but same issue. When I go to the subdomain of "2" in this screenshot, it loads but it shows me the webpage and content that are from site "1"…
Can you post your apache2 configurations for “1” & “2”? The *.conf files in /etc/apache2/sites-available…
Copy/paste the contents of each file between two sets of ``` (backticks…next to the 1 key) on separate lines. Like this:
This is 'code' content.
— sw
Thank you again,
SITE 1
This was the first site I had on Linode, and just used the IP address of my linode as the directory, as I wasnt sure what else I would do
The DOMAIN_ON_LINODE_NAMESERVERS for this one is purchased on google domains, but I pointed the Nameservers to linode
<Directory /var/www/html/public_html/123.456.789>
Require all granted
</Directory>
<VirtualHost *:80>
ServerName subdomain.DOMAIN_ON_LINODE_NAMESERVERS.com
ServerAlias subdomain.DOMAIN_ON_LINODE_NAMESERVERS.com
DocumentRoot /var/www/html/public_html/123.456.789/
ErrorLog /var/log/apache2/123.456.789/error.log
CustomLog /var/log/apache2/123.456.789/access.log combined
</VirtualHost>
SITE 2
This is the second site, I used a name for the directory this time
The DOMAIN_HOSTED_ELSEWHERE is also purchased on google but I went there and created a subdomain A record and pointed it to my linode IP address
<Directory /var/www/html/public_html/siteTwo>
Require all granted
</Directory>
<VirtualHost *:80>
ServerName siteTwo.DOMAIN_HOSTED_ELSEWHERE.com
ServerAlias siteTwo.DOMAIN_HOSTED_ELSEWHERE.com
DocumentRoot /var/www/html/public_html/siteTwo/
ErrorLog /var/log/apache2/siteTwo/error.log
CustomLog /var/log/apache2/siteTwo/access.log combined
</VirtualHost>
Sorry, I just saw this…
You can do this (using siteOne as an example):
<VirtualHost *:80>
ServerName subdomain.DOMAIN_ON_LINODE_NAMESERVERS.com
ServerAlias subdomain.DOMAIN_ON_LINODE_NAMESERVERS.com
DocumentRoot /var/www/html/public_html/123.456.789/
ErrorLog /var/log/apache2/123.456.789/error.log
CustomLog /var/log/apache2/123.456.789/access.log combined
<Directory /var/www/html/public_html/123.456.789>
Require all granted
</Directory>
</VirtualHost>
More of a stylistic thing than anything else… It's not a good thing to put your logs with your site content. Put them in /var/log where they belong (you can also cause them to be rotated automagically using a file in /etc/logrotate.d for that purpose).
The DOMAIN_HOSTED_ELSEWHERE is also purchased on google but I went there and created a subdomain A record and pointed it to my linode IP address
I don't understand why you did this… It should work but it seems to be unnecessarily complex to me. Complex = error-prone, IMHO.
Does
ping subdomain.DOMAIN_ON_LINODE_NAMESERVERS.com
resolve to your Linode IP address? If not, that's probably your problem.
-- sw
Thank you,
first off yes, pinging either subdomain both resolve to my linode IP
I setup the subdomain/A record point so that the subdomain would know where to go… I have the TLD resolving to my main site elsewhere but I wanted a subdomain of THAT domain to be the one on linode, I cannot move the main site over to linode yet.
I just cant see why going to one subdomain would direct to the files of the other directory ha
Sorry, I appreciate you sticking with me here lol
You it wound up being a typo oh my gosh I feel so bad, thank you for your time!