how to access vagrant box "guest machine" from host machine? - laravel

I am using puphpet.com tool to set up Vagrant boxes.
Now , I am able to ssh to it and open the IP on the browser but I can not get to access the VHost I set up earlier through puphpet.
I have edited my hosts file (/etc/hosts ) "using OSX" to serve the IP 2.168.56.101 to lab.dev. Now it works fine but I can not access the virtual machine on the guest machine !!!!.
I am using PHP Laravel framework and I need to access the server name which points to /var/www/lab.dev/public/. I would appreciate very detailed answer as I am really new to all of this

Detailed Instructions
Visit PuPHPet.com to build your Vagrantfile.
Configure your Shared Folder Pairs. This is under "Deploy Target > Locally".
Let's assume this directory structure on your OS/X machine:
/Users/unrivaled/Documents/laravel-project (project files go here)
/Users/unrivaled/Documents/laravel-project/public (the web root files)
Folder Source represents the location on your main computer (the "host" operating system), where your source files reside; for example: /Users/unrivaled/Documents/laravel-project The Folder Source must be on your OS/X machine, exactly where your Laravel files are.
Folder Target represents the location on your virtual computer (the "guest" operating system), where you want Vagrant to make them visible to the web server; for example: /var/www/lab The Folder Target can be anywhere that Apache or Nginx, in the virtual machine, can reach it.
Folder Source (local machine) == Folder Target (virtual machine)
/Users/unrivaled/Documents/laravel-project (local machine) == /var/www/lab (virtual machine)
Configure your web server. Your Server Name can be anything you want; in this example, let's use "lab.dev". Configure your Server Alias; in this case, use "www.lab.dev." Your Server Name (or an alias) must match your entry in your /etc/hosts file; see below. Configure your Document Root. This is the folder on your virtual machine where your website files will go and the files that will be served by Nginx or Apache. This value must be at, or below, the Folder Target defined from Step 4; for example, /var/www/lab/public.
Notice in the example how we are giving the web server access to /var/www/lab/public? This actually refers to /Users/unrivaled/Documents/laravel-project/public on your local OS/X system, thanks to the "Shared Folder Pairs" configured in Step 2., above.
Generally, configure everything else in PuPHPet as you see fit.
Run vagrant up to get your virtual machine up and running. If it doesn't work at this stage, you need to resolve any problems before going on.
Determine your virtual machine's IP address. Use vagrant ssh to log into the virtual machine, and then ifconfig should work for this. Do not rely on the IP address defined in PuPHPet. Your virtual machine provider will likely override this value, and you need to know the actual, in-fact IP address.
On your main host computer (not the virtual machine), edit your /etc/hosts file: sudo nano /etc/hosts, adding the server's IP address, followed by the Server Name (or a Server Alias) defined in Step 5, above.
How It Works
Once you have a working web server using the settings in this example, you can view your website by going to lab.dev. Your browser in OS/X will resolve lab.dev to the proper IP address of your server by way of the /etc/hosts file. It then requests your web page from that IP address, where the server matches the requested resource, "lab.dev," to the appropriate Server Name or Server Alias that matches. The files in the Document Root for that server name (/var/www/lab/public) will be processed by the web server.
In summary, your server's IP address in the local /etc/hosts file matches your server's IP address in the virtual machine; your server's name in the local /etc/hosts file matches your Server Name (or Server Alias) in the web server on the virtual machine; the path name to your project source files on your local computer (Folder Source) maps to the Target Directory on the virtual machine; and finally, a subdirectory of that target directory (public) corresponds to the Document Root for the web server.

Related

Use a domain like name to access a test site instead of an IP address

I'm currently testing a few websites on Ubuntu Server installed on Oracle VM Virtual Box on a Windows 11 machine.
I need to type an IP address to access these sites (eg: 192.168.xxx.xxx).
Is it possible to use something like a domain name to access them instead of using an IP address? Like mysite1.com, mysite2.com etc.
I'm not using domain names booked on godaddy or some place like that. Just names for local testing. How can it be done in this scenario? Everything is installed on the same machine.
Add your sites to /etc/hosts file like this:
192.168.... mysite.domain
Yes, you can go to /etc/hosts and apply IP you are using and the domain name you want:
Example.
Open with:
sudo nano /etc/hosts
apply:
192.168.x.x mysite.com
And restart server.
TRY CLEAN CACHE
sudo apt-get install nscd
AND NOW
sudo service nscd restart
or
sudo service dns-clean
To restate your setup, you have one Ubuntu server guest VM (in VirtualBox) running on Windows 11. Because you mentioned the 192.168.x.x IP range I will assume the guest VM is on a "bridged" vbox network adapter that any device on your local network can ping. I also have to assume the IP address(es) you are using are successfully connecting you from your Windows 11 host to your Ubuntu guest. Is all this correct? Does your VM have a desktop and a web application that can reach popular sites on the internet? Does the Ubuntu OS use DHCP or a static IP assignment?
The short answer is yes, you can use domain names instead of IP addresses. If you are not successful connecting to the IP address, switching to domain names will not help you. You have to have all the network dependencies satisfied first.
To choose a domain name for testing;
You should take a look at RFC 6761. Specifically at secion 6; 6.1 - 6.5
https://www.rfc-editor.org/rfc/rfc6761.html
.in-addr.arpa.
10.in-addr.arpa. 21.172.in-addr.arpa. 26.172.in-addr.arpa.
16.172.in-addr.arpa. 22.172.in-addr.arpa. 27.172.in-addr.arpa.
17.172.in-addr.arpa. 30.172.in-addr.arpa. 28.172.in-addr.arpa.
18.172.in-addr.arpa. 23.172.in-addr.arpa. 29.172.in-addr.arpa.
19.172.in-addr.arpa. 24.172.in-addr.arpa. 31.172.in-addr.arpa.
20.172.in-addr.arpa. 25.172.in-addr.arpa. 168.192.in-addr.arpa.
.test.
.localhost.
.invalid.
.example.com.
.example.net.
.example.org.
You may have to create/modify the \windows\system32\drivers\etc\hosts file that Windows uses to intercept asking DNS for IP/host mapping. If you are using a linux/unix client, the /etc/nsswitch.conf AND /etc/hosts files could override DNS for you. This may or may not be in the same location on Windows 11 but as of Windows 10 21H2 it was still there.

How to use Windows hosts file to access my website url from another laptop or system

I have done a project using Netbeans 8.2, Apache Tomcat 8, MySQL database (XAMPP). My OS is Windows 10. It is successfully executed on my laptop.
Now I am trying to access my project url (http://dms.zf.com:8084/newFieldsAdded/login.jsp) from another laptop but failed. So I searched the web and I got solution like this. I added
10.226.43.47 dms.zf.com
My laptop IP address and name into hosts (C:\Windows\System32\drivers\etc) file. Then I tried with this url (http://dms.zf.com:8084/newFieldsAdded/login.jsp) on my browser, it is successful. but it is not accessible from other laptop.
Before doing changes in hosts file url was http://localhost:8084/newFieldsAdded/login.jsp and after adding 10.226.43.47 dms.zf.com in hosts file URL is http://dms.zf.com:8084/newFieldsAdded/login.jsp.

IIS on a virtual machine on a shared folder

I'm running Arch with a Windows 10 virtual machine and I'm trying to run an IIS server with an application in a shared folder. When I try to browse to it, I'm given a 500.19 error "cannot read configuration file". I know the application works under a normal Windows environment but I need the application to be in a shared folder under a virtual machine.
The shared folder is located in /home/hayden/virtual/shared.
What am I doing wrong?
Does IIS have permission to the folder? See this post on how to do that.

xdebug remote server and SFTP - cannot connect

I am trying to debug PHP files which sit on a remote server (on the same network) without success.
Here is my php.ini config for xdebug on the remote server where PHP and xdebug are installed:
xdebug.remote_enable=1
xdebug.remote_host=192.168.128.56
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_autostart=0
192.168.128.56 is the IP address of my PC on which my editor is installed.
I have tried to get this working with both Atom and Sublime Text 3 without success. I think that my path bindings may be incorrect.
I log into the remote linux machine using SFTP. I can then double click on php files in my application and they will open in my editor where I can work on them and save them. How can I set up the path bindings to debug these remote php files? I'm not sure what the second (local) part of the path binding should actually be? Do I need to add the location where the FTP software stores a temporary copy of the file I am working on as the local part of the binding?
I have tried the following:
URL - the address of where the app runs on the remote server:
e.g. http://www.mywebsite.com/testapp/
Path Binding - remote path to the application root on linux : path to the local copy of the files on my machine where the FTP software stores them:
e.g. /web/testApp/ : C:\Users\me\AppData\Local\Temp\scp18929\
I'm a little confused about how the path binding works, and what the values should be. Am I doing this correctly? Can this even be done?
If anyone can help that would be great.
Probably, the first thing to check is whether Xdebug actually tries to connect to your IDE. You can do that, by adding:
xdebug.remote_log=/tmp/xdebug.log
to your php.ini file. When you then initiate debugging, there should be information in the /tmp/xdebug.log file, where it will tell you where it tried to connect too, and whether the connection succeeded or failed.
If you get something like:
I: Remote address found, connecting to 192.168.128.56:9000.
E: Could not connect to client. :-(
That means that either your IDE wasn't listening for something, or that there is a firewall preventing an incoming connection, or that the IP address is incorrect.

Redirect URL on Windows (local dev environment)

I'm setting up a local dev environment, as part of this I need to redirect a domain name (including all subdomains) to a local IP address.
I have achieved this on Linux using dnsmasq with this line in the config:
address=/example.com/10.0.19.12
This looks like it will also work on OS X, but I now need the same effect on Windows. How would I get a Windows machine to do this too?

Resources