D
D
dani1a2015-09-09 21:42:20
Apache HTTP Server
dani1a, 2015-09-09 21:42:20

How to properly configure apache on 2 domains?

Generally there are 2 domains. I add the following code to httpd.conf

<VirtualHost domen1.ru:80>
ServerName domen1.ru
DocumentRoot /var/www/domen1.ru
</VirtualHost>



<VirtualHost domen2.ru:80>
ServerName domen2.ru
DocumentRoot "/var/www/html"
</VirtualHost>

As a result, domain1 works correctly. And domain2 displays the contents of the domain1 folder. What am I doing wrong? I tried to create separate configs for each domain, the result is the same. AXIS CENTOS. Tried to start through the panel also, the result is the same

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan Fedoseev, 2015-09-09
@dani1a

NameVirtualHost abcd:80
< VirtualHost abcd:80>
ServerName domen1.ru
...
< /VirtualHost>
< VirtualHost abcd:80>
ServerName domen2.ru
...
< /VirtualHost>
you would read the logs of the server, it obviously complains to you about that that domains overlap each other
And it’s better not to call virtual hosts by domain name, but by address

D
dani1a, 2015-09-09
@dani1a

Ruslan Fedoseev : tell me more if it's not difficult. And if I need domen2.ru to still be visible via https. I add code like this

<VirtualHost domen2.ru:443>
ServerName domen2.ru
DocumentRoot /var/www/html
        SSLEngine on
        SSLCertificateFile /etc/pki/tls/certs/domen2_ru.crt
        SSLCertificateKeyFile /etc/pki/tls/private/ca.key

</VirtualHost>

But domain2 on https gives an SSL error. Separately naturally works. Again, apparently screwed up with the names?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question