Apologies in advance if I this question has been answered elsewhere (I seem to remember reading a post, but can't find it anywhere).

Currently, to access websites in the guest from the host I am editing '000-default' in the 'config' directory and changing occurrences /var/www to the location of a particular site e.g. /home/quickstart/websites/example.dev.

	DocumentRoot /home/quickstart/websites/example.dev
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /home/quickstart/websites/example.dev>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>
	DocumentRoot /home/quickstart/websites/techno.dev
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /home/quickstart/websites/techno.dev>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>

Comments

pau1_m’s picture

Woops, I hit save instead of preview and hadn't finished editing. I meant to say...

At the moment, to access a site in the guest from the host I change

	DocumentRoot /var/www
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /var/www>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>

to

	DocumentRoot /home/quickstart/websites/example.dev
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /home/quickstart/websites/example.dev>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>

and then change networking from NAT to Bridged and run

sudo apache2ctl restart

Is there a more elegant solution for this?

Would it be possible to have something like 'localhost/mysites' or 'localhost:8080' point to '/home/quickstart/websites'? With an appropriate .htaccess in that directory one could access all of the sites on the guest from the host.

I have found Firefox, Chrome and Chromium all have random problems with JavaScript and Flash so it's really important to be able to check sites with browsers on Mac / Windows.

pau1_m’s picture

Forgot to say, also have to change a line in 'example.dev' in the 'config' dir to the current IP of the guest.

from

<VirtualHost *:80>
  ServerName example.dev

to

<VirtualHost *:80>
  ServerName 192.168.0.8

And then type the IP into a browser on the host to access the site.

Is really not a very elegant solution the problem, but it works for the moment. Any thoughts on how to improve?

pau1_m’s picture

Whilst writing the above, I got to thinking about different ways to approach this problem. At the risk of turning this support request in to a stream of consciousness I'll post a new (simpler) solution.

First, add a new listening port to Apache. In this example I'm going to use port 55555.

In ports.conf located at

/home/quickstart/websites/config/ports.conf

Add this line to the end of the file

NameVirtualHost *:55555
Listen 55555

Now we tell apache to point this port to example.dev. Edit the file at

/home/websites/config/apache-sites-enabled/example.dev

and change the first line

<VirtualHost *:80>

to

<VirtualHost *:55555>

In the terminal, restart Apache

sudo apache2ctl restart

Ensure that networking mode is Bridged rather than NAT.

You should now be able to access example.dev from a browser on the host (or any other machine on the network) by entering the guests IP and sites port number. In my case this is

http://192.168.0.8:55555

or on the guest at

http://localhost:55555

This procedure can be followed for any number of sites - just use different port numbers for each.

edit: There's a solution for the same issue on a quickstart handbook page. But this one is not dependent on fixed IPs or making changes to the host OS.

MichaelCole’s picture

Status: Active » Fixed

Hi pau1_m,

All these things are possible... I don't have any special feedback.

I hope you find what works for you.

Best luck,

Mike

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

danny_joris’s picture

Component: Miscellaneous » Image Build

Thanks Paul, #3 worked great for me! For newbs like me: an easy way to find out the guest IP is to right click the 'network connections' icon on top, and choose 'connection information'. You can find the IP Address there. (mine was 192.168.1.7)

danny_joris’s picture

Is it possible to connect with ftp or ssh to the Guest OS as well using this technique?

danny_joris’s picture

Actually this solution made me understand the one in the documentation better: http://drupal.org/node/789006 . I'm using this solution now using NAT & Host-Only and the hosts files. Awesome!

Still wondering on how to get access from the Host to the Guest using FTP and SSH (putty?).

danny_joris’s picture

Solved (s)FTP and SSH (putty) by installing OpenSSH on the Guest OS. Instructions are here: https://help.ubuntu.com/10.04/serverguide/C/openssh-server.html . Only need to install openssh-server on the Guest OS if you're using Putty (as far as I know).

This is great! :)

rootwork’s picture

I've edited the handbook page and added all of the options mentioned here:
https://drupal.org/node/789006

rootwork’s picture

Component: Image Build » Documentation
danny_joris’s picture

Thanks for adding this. I saw the note about bridged networking. Just want to say that it runs very well and I only use NAT and Host-Only.

Cheers!