Zend Server CE, After Uninstall, localhost doesn't work - php

This is odd...
I installed Zend Server to test it out. Turns out I don't like it and I wanted to go back to MAMP. But after the Zend Server CE uninstall, "localhost" no longer works. I can only access MAMP from 127.0.0.1
Frustrating and I'm not liking it at all.
Any ideas?
hosts:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 mydomain.loc www.mydomain.loc
nslookup says:
Server: 64.59.160.13
Address: 64.59.160.13#53
Non-authoritative answer:
Name: localhost
Address: 127.0.0.1

I was told by a college that sometimes the only thing you can do to wake up port 80 on the Mac is to enable the built in web server and then disable it again.
So I did that and all is well.

you mention 127.0.0.1 which is a IPv6 address. Many (all?) modern operating systems are configured to resolve localhost using IPv6 to ::1. My assumption would be that your MAMP setup is not listening via IPv6. Try opening http://[::1]/ if that works there is an error in our resolve configuration, if not (what I expect) you have to configure your web server to either lsiten to ::1 or any device.
This can be done in httpd.conf using
Listen 80
to listen on all devices, port 80 or
Listen [::1]:80
to listen to localhost via IPv6 only. Mind not having conflicting VHost entries etc.

Related

Webserver not listening to ports

Problem
I've recently found out that PHP has a built-in webserver which can be used for development purposes. Starting the server with the address "127.0.0.1" and the port "8080" works without any problems and my requests are handled properly. However, if I dare to use the address "localhost" with the same port, the webserver doesn't handle any requests.
Specs
Windows 10 64-Bit
Php 64-Bit Thread-Safe installed
MongoDB installed (Not running)
IIS Server installed and running
MariaDB installed (Not running)
Name resolution for localhost is handled by your DNS server which is likely resolving it to the IPv6 address ::1.
If you run:
php -S 127.0.0.1:8080
The webserver is running on the IPv4 address but localhost resolves to the IPv6 address.
So you can either use 127.0.0.1:8080 in the browser address bar.
Or force the address by un-commenting the following line from C:\Windows\System32\drivers\etc\hosts:
# 127.0.0.1 localhost
Or bind the webserver to the IPv6 address (this is what I do):
php -S localhost:8080

Ratchet WebSocket won't work over Vagrant machine

I have a WebSocket server using Ratchet (literally the example app). I'm serving it to localhost:8080 on my Vagrant machine (which is a CentOS 6) and trying to connect to it through the private network IP set in the Vagrantfile 192.168.33.10.
I'm getting a connect ECONNREFUSED 192.168.33.10:8080 (the uri is ws://192.168.33.10:8080/chat).
I already exposed the port config.vm.network "forwarded_port", guest: 8080, host: 8080.
I've tried serving the server (inside vagrant) to localhost, 127.0.0.1 and 192.168.33.10, but the client still can't connect.
It works fine outside of Vagrant using localhost on both client and server.
What am I missing?
If you bind the app to localhost there is no way you can access it via 192.168.33.10, hence port forwarding won't work either.
You need to make your app to listen on 192.168.33.10:8080.
Also add the guest's IP address to the Vagrantfile:
config.vm.network "forwarded_port", guest_ip: "192.168.33.10", guest: 8080, host: 8080

localhost and 127.0.0.1 doesn't get the same page

It will show different page when I visit localhost and 127.0.0.1 , I don't know what happened.
My hosts has bind 127.0.0.1 and ::1 to localhost. Like this:
127.0.0.1 localhost
::1 localhost
When I visit localhost it is ok. It shows me the index.php which in the root dir. I want to know why localhost and 127.0.0.1 get the difference page and which file 127.0.0.1 visited?
I use wnmp.
ps: when I ping localhost, it shows me ::1.
Can anyone help?
Comment those out in host
# 127.0.0.1 localhost
# ::1 localhost
It is predefined already. It is not possible that they are showing different pages since they point to your local ip and the same port 80. Is your wamp fresh installed? you might have configured like the vhost.

Cannot access site from host machine on a vagrant virtual machine

I setup a nginx+mysql puphpet/vagrant image, with a virtual host "test.com". I mapped test.com to 192.168.56.101 on the host machine, and put an index.php file inside /var/www/test.
However, when I try opening the browser at the address test.com on the host machine I get no response. I feel like I'm missing something really simple, because I can ping 192.168.56.101. I also checked nginx logs on the virtual machine, but they are empty. Any clues where the problem might be? Am I not supposed to use it this way? I can ssh into vagrant just fine, and also I can access the mysql db.
In your Vagrantfile, you need to forward the port to your host machine.
For example map port 80 of the Vagrant machine to port 8080 of the host machine.
config.vm.network "forwarded_port", guest: 80, host: 8080

Vagrant VM shows "SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1" in browser when navigating to "127.0.0.1:2222"

Why ?
I've set up an extremely simple server, like 50 times before, but this is my first try with Vagrant.
Current behaviour:
Vagrant VM shows "SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1" in browser when navigating to "127.0.0.1:2222". 2222 is the standard port for the first Vagrant VM.
Expected behaviour:
127.0.0.1 should show the index.html/php of the apache2 web folder.
When you run a vagrant up, you'll see a message showing [default] Forwarding ports... -- 22 => 2222 (adapter 1). ssh is listening on port 22 on your VM, you can ssh to port 22 (default) from your local box to connect to the VM; but if you have configured the VM to allow external access, then anyone else on another machine needs to use your IP address but port 2222 to connect to the VM.
This might be useful if you ran the VM on a box in work, but wanted to be able to access it when you were at home, or in a client's office, or even from another machine in your work's network.
Using a browser to connect to the SSH port 2222 will redirect to port 22 on the virtual box, but it's ssh that's listening on this port; and a web-browser isn't the right tool for an ssh connection.
Personally I use putty as my ssh client, but with vagrant you can also issue a vagrant ssh after starting the virtual machine.
Additional
The values of port forwarding
If you set
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 443, host: 8443
in your vagrantFile, and you've allowed public access to the VM, then you can access the webserver on the VM from home, a client or another box in your work network by pointing the browser to port 8080 (or 8443 for https) rather than the more normal default ports 80 and 443... which can be particularly useful for running demos from a laptop that you can take to a client site while your VM is running on a bulky desktop under your desk in work
MarkBaker's answer solves the problem, but Vagrant 1.2.7 (and newer) needs this syntax:
# Forward guest port 80 to host port 80
config.vm.forward_port 80, 80
The full Vagrantfile (you can find it where your box file is) would look like this:
Vagrant::Config.run do |config|
# Forward guest port 80 to host port 80
config.vm.forward_port 80, 80
end
This example would route a request on port 80 (standart port) in your host OS to port 80 in your Vagrant VM. The result is, http://127.0.0.1 in the host browser will show you the localhost of the VM.
When working with multiple VMs please notice that you should use a unique port for every VM.

Categories