D
D
D44k2015-12-15 15:08:43
linux
D44k, 2015-12-15 15:08:43

Apache2 virtual host why not redirect?

Good day.
There is a VPS, the domain is delegated, DNS is configured and working.
Created my own virtual hosts config in /etc/apache2/sites-available/site.ru.conf folder Site
directory /var/www/site.ru

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName site.ru
    ServerAlias www.site.ru
    DocumentRoot /var/www/site.ru
    ErrorLog /var/log/apache2/site/error.log
    CustomLog /var/log/apache2/site/access.log combined
    <Directory /var/www/site.ru>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Config enabled via a2ensite site.ru, server rebooted When trying to open site.ru
redirects to the standard /var/www/html directory
the standard config 000-default works
Tell me what I forgot to do?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
Yuri, 2015-12-15
@D44k

apache2ctl configtest && apache2ctl graceful
??
Have you restarted Apache? Is site.ru mentioned anywhere else in the configs?

R
romy4, 2015-12-15
@romy4

first compare the address from nslookup site.ru and apache2ctl -S with the IP hosting the virtualhost

D
D44k, 2015-12-15
@D44k

Yuriy romy4
Config test OK, rebooted, ip matches

apache2ctl -S
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server site.ru (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost site.ru (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost site.ru (/etc/apache2/sites-enabled/site.ru.conf:1)
                 alias www.site.ru
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

As far as I understand, the default config just processes site.ru, can I just turn it off through a2des or is there a more correct way?
ldv000
-default.conf:
<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot /var/www/html

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question