Setting up vhost on VirtualBox with Ubuntu 16.04 [duplicate]

I am pretty new to development and this is why I am stuck at such a “beginners” problem.

I want to have a directory under /var/www/mysite with a index.html and access it via web browser on my PC (Win10 64 Bit) by typing mysite.example into it.

I don’t want to publish anything into the internet with that. I only want to test and develop a site which later might be hosted.

I have created a VirtualMachine using Oracle VirtualBox and installed Ubuntu16.04 (64-Bit, also enabled Virtualization at my i5 2500 in Bios so I get these 64-Bit displayed).

Then I installed apache2, mysql and php.

ip addr show gave me an address: 192.168.178.31.

So if I type into my browser http://192.168.178.31/ I get to the apache2 default page – It works!

I created the directory /var/www/mysite and put a simple index.html for testing purpouse into it. I said sudo chown -R 775 to /var/www/.

Now I need to create a vhost so I can access to this index.html in this specific directory by typing in a specific string into my browser. But it just won’t work!

I went to /etc/apache2/sites-available/ and created mysite.conf.

This is the content:

<VirtualHost *80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mysite
ServerAlias mysite.example
</VirtualHost>

I did a2ensite mysite.conf, sudo service apache2 reload and restart

So there I am. If I type mysite.example into my browser I only get errors.

Site not reached. DNS-Server for mysite.example not found and so on (ERR_NAME_NOT_RESOLVED).


Go to Source of this post
Author Of this post: nico
Title Of post: Setting up vhost on VirtualBox with Ubuntu 16.04 [duplicate]
Author Link: {authorlink}