LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Centos7, Apache, subdomains and .conf-file configuration (https://www.linuxquestions.org/questions/linux-software-2/centos7-apache-subdomains-and-conf-file-configuration-4175634575/)

Basher52 07-20-2018 07:56 PM

Centos7, Apache, subdomains and .conf-file configuration
 
Hi all.

system used:
Code:

uname -a
Linux aaa.bbb 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux


I installed a server(I'm in a hurry again) about 1,5 weeks ago using CentOS 7 and after about 5 minutes of googling I found out the how .conf-files should be of a subdomain.
It all worked OK but later I did the thing a Linux Admin SHOULD NOT DO!!!!
Using runninglevel 3(as always) I changed to a directory, as I thought, but I wrote a little wrong so I happened to be in root-dir and there I did 'rm -rf'. I saw what happened so I CTRL-C it but as I knew, that system was gone.

Now I reinstalled it again but THIS time I just can not find the apache-subdomain-conf-file-example-thing and I just can't get it to work.
I've been doing this for 5 days now and still nothing works.

'DocumentRoot' is set to the directory of the main domain name.

As I can't recall at all how the conf-file looked like I gotta ask;

YES, I googled my a$$ of for this, this 2nd time and nothing works. Also tried different browsers on different devices and still nothing, so no cash problems :(

-?- Do I have to have the subdomain-directives in the same .conf-file as the 'main' domain as some google-result says? (tried that and it didn't work, if I did it correctly)

I probably have missed showing you info about the system but I don't know what to show.
It's a "normal" CentOS 7 installation and its' versions all the latest applications.

I'm about to give up even though I already got it working like 1 week ago.

bathory 07-21-2018 02:58 AM

Quote:

Now I reinstalled it again but THIS time I just can not find the apache-subdomain-conf-file-example-thing and I just can't get it to work.
I've been doing this for 5 days now and still nothing works.

'DocumentRoot' is set to the directory of the main domain name.
<-snip->
-?- Do I have to have the subdomain-directives in the same .conf-file as the 'main' domain as some google-result says? (tried that and it didn't work, if I did it correctly)
To configure a vhost (or subdomain as you say it) for apache in Centos, read this howto (esp. #6).

If /etc/httpd/conf.d/vhost.conf does not exist, you can create it using the example in the link above as a template.
FYI apache reads all .conf files under /etc/httpd/conf.d at startup.

Basher52 07-21-2018 06:11 AM

Well it's not a vhost I'm after. I want to add subdomains under domainname.com like

aaa.domainname.com, bbb.domainname.com, ccc.domainname.com etc
All other things with "normal" domainnames work perfectly just this thing with subdomains that won't work.
I own a real domainname and I want to add more other sites to it but by using the above subdomains.

bathory 07-21-2018 07:31 AM

Quote:

Originally Posted by Basher52 (Post 5881960)
Well it's not a vhost I'm after. I want to add subdomains under domainname.com like

aaa.domainname.com, bbb.domainname.com, ccc.domainname.com etc
All other things with "normal" domainnames work perfectly just this thing with subdomains that won't work.
I own a real domainname and I want to add more other sites to it but by using the above subdomains.

Any subdomain is actually a vhost, so you should follow the same setup.
Or else, post the config that is not working and the error you get so we could help you better on that.

Basher52 07-21-2018 10:16 AM

Well ain't that typical :( today it worked and I've been trying this for almost a week now.
I tried different types that I googled up and this is supposed to work and it does, like all subdomains in the same conf-file as where the main domain was, which ALSO works now.
Just can't figure out why it didn't work the other days. As I said, I flushed all browsers and tried on different PCs and mobile devices.

Ah well, it works so I'm glad :D

This is what I have now
Code:

<VirtualHost *:80>
    ServerName sub1.domain.com
    DocumentRoot /webdata1/sub1
    ErrorLog /var/log/httpd/sub1.domain.com-error.log
    CustomLog /var/log/httpd/sub1.domain.com-access.log combined
</VirtualHost>

I got four of these all in separate files under .../conf.d/
All of them works as subdomain under domain.com, like:
http://domain.com show one site, the main one.
and these;
http://dom1.domain.com
http://dom2.domain.com
http://dom3.domain.com
http://dom4.domain.com

all shows different sites

Marking this post solved
and thanks :D


All times are GMT -5. The time now is 02:30 AM.