configure virtual host in apache2

Asked

Viewed 143 times

3

I am having difficulty configuring my virtual host in Apache2 with Debian.

I created the folder:

mkdir /var/www/site/public_html

inside that directory I created a file index.html.

After that I set up the virtual host like this:

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

Here if I will access through the url http://192.168. 0.100/website, does not access the page, only if accessed by http://192.168. 0.100/site/public_html.

Where I’m going wrong 'cause I got all lost in it.

2 answers

2


Virtualhost is valid when you access 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 off Servername/Serveralias, or create a second Virtualhost configuration without these items, it will catch as default.

1

In apache settings (httpd.conf), look for the directive NameVirtualHost. If there is one, deactivate it.

In the Virtualhost tag, set the server ip:

<VirtualHost 127.0.0.1:80> 

IP 127.0.0.1 is illustrative. Exchange it for the server IP.

Be aware that there are some differences between Apache 2.2 and 2.4 that may affect the operation.

See the documentation: http://httpd.apache.org/docs/2.4/upgrading.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.