Apache 2.4 virtual host is ignored

I am creating a new web server using Ubuntu 14.0, following the instructions here for creating virtual hosts, however my only additional virtual host always loads the default site (/ var / www / html).

Here is my vhost configuration (I replaced my example.com domain, but otherwise it is identical):

<VirtualHost *:80>
  ServerName example.com
  ServerAlias www.example.com

  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/example/app

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

I DID NOT CHANGE OTHER CHANGES in the Apache 2.4 configuration that is installed on Ubuntu 14.

EDIT: I correctly resolve sites and restart apache after making changes to this vhost.

When I visit example.com in my browser, I get the default site. What am I doing wrong? How to force a virtual host to load the correct directory?

EDIT: "sudo" (qaru.site/questions/195211/...).

+5
5

apache vhost, enable vhost. :

sudo a2ensite example.conf (name of config file inside sites-available directory)

:

sudo service apache2 restart

www, , Apache .

0

?

NameVirtualHost *:80
0
0

, . :

webmaster@ubuntuserver:/srv$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial
webmaster@ubuntuserver:/srv$
webmaster@ubuntuserver:/srv$ apache2 -v
Server version: Apache/2.4.18 (Ubuntu)
Server built:   2017-09-18T15:09:02
webmaster@ubuntuserver:/srv$

:

<VirtualHost *:80>
ServerAdmin admin@testsite.com
ServerName testsite.com
ServerAlias www.testsite.com
DocumentRoot /var/www/testsite
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

, :

  • ;
  • chmod 774;
  • ;

, :

Listen 80

, :

Listen 80
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName testsite.com
ServerAlias www.testsite.com
DocumentRoot /var/www/testsite
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

.

, , Listen 80. , , , Listen 80.

, Apache:

https://httpd.apache.org/docs/2.4/bind.html

0

Try running the apachectl command with the -t option, this will verify that the whole configuration is correct. Which file is this virtual host. Have you restarted apache to get these changes?

apachectl restart
-1
source

All Articles