configure virtual host on apache2 [duplicate]

3

I'm having trouble setting up my virtual host on Apache2 with Debian.

I created the folder:

mkdir /var/www/site/public_html

Within this directory I created a index.html file.

After that I configured the virtual host like this:

<VirtualHost *:80> 
 ServerName site.org
 ServerAlias www.site.org
 DocumentRoot /var/www/site/public_html/
</VirtualHost>

So if I'm going to access through the url link , it does not access the page, only if you access it by link .

Where I'm wrong, because I've lost all of it.

    
asked by anonymous 29.09.2015 / 02:10

2 answers

2

VirtualHost is valid when you login with the specified name (in this case, site.org) because it exists to serve multiple sites using a single server. Access via IP will pick up the default site, which is not site.org. I think if I comment out the ServerName / ServerAlias, or create a second VirtualHost configuration without these items, it will pick up as default.

    
29.09.2015 / 03:18
1

In apache settings (httpd.conf), look for the NameVirtualHost directive. If it exists, disable it.

In the VirtualHost tag, set the server ip:

<VirtualHost 127.0.0.1:80> 

IP 127.0.0.1 is illustrative. Swap it over the IP of the server.

Be aware that there are some differences between Apache 2.2 and 2.4 that can affect how it works.

See the documentation: link

    
29.09.2015 / 03:45