simonewebdesign

How to put online your WampServer

WampServer LogoOn your Windows machine you run an Apache web server with some PHP websites in there. What if you want to show all of them to your friends, or want to be reachable by the whole Internet? This may sound quite difficult to achieve, but actually it’s fairly straightforward to put online a web server: let’s see how.

Publishing your Website on the Internet

First of all, you need to get your WAMP stack up and running on your local host. I’ll assume you already have a web application hosted on your own PC, and that is reachable by just typing this URL in the address bar:

http://localhost/    # or http://127.0.0.1

Now you should access to your router web interface. Usually it is reachable by navigating to:

http://192.168.1.1

However this may vary, depending on your router model. When in doubt, open the command prompt (cmd), type ipconfig and press enter. You should see something like this:

C:\>ipconfig

Ethernet adapter Local Area Connection:

  Connection-specific DNS Suffix  . :
  IP Address. . . . . . . . . . . . : 192.168.1.27
  Subnet Mask . . . . . . . . . . . : 255.255.255.0
  Default Gateway . . . . . . . . . : 192.168.1.1

Please take note of the IP address: that’s your private address, which uniquely identifies you in your local network. If you try it in your browser, you should be able to see the public contents of your server.

Port Forwarding

In order to be reached by the world, you should tell your gateway where is your web server. All incoming request on port 80 should be redirected to your own private IP address. Even this process may vary; it really depends on your router. By the way, this is what you basically want to do: forward every request on port 80 to 192.168.1.27 (of course you must use your own IP address). But since the router’s web server already keeps the port 80 busy, here’s what you can do:

  • Move the gateway’s web interface to another port;
  • Move your web server to another port.

I’ll pick the last one, since it’s usually easier to do, and the first option is not always possible. So, let’s change the port: open the httpd.conf and find this row:

Listen 80

replace it with:

Listen <port number>

for example:

Listen 8080

And restart the server. Now go to http://localhost:8080 and check that everything went as expected.

Routing the outside web traffic to your own web server

All respectable routers have an advanced section called IP/Port Forwarding: find yours. If you don’t have this, I’m afraid you cannot be reachable by the outside.

Usually you need to add two separate entries: one for TCP and one for UDP packets. Something like this will do the work:

Private IP     Private Port   Type   Public IP/mask   Public Port
192.168.1.27   8080 	      TCP    0.0.0.0/0        8080
192.168.1.27   8080 	      UDP    0.0.0.0/0        8080

Apply the changes and restart your router.

Configuring the server to be reachable by everyone

The last step! Open your httpd.conf and find this line:

ServerName localhost:80

Change it to:

ServerName <your private IP>:80

Example:

ServerName 192.168.1.27:80

Just a quick note: you can jump over the step below. It can be done in an easier way by just clicking on the green WampServer tray icon and choosing “Put Online”.

Also find this line:

#   onlineoffline tag - don't remove
    Require local

Change it to:

#   onlineoffline tag - don't remove
    Require all granted

In older versions of Apache, the line would look like:

Order Deny,Allow
Deny from all
Allow from 127.0.0.1

And you need to change it to:

Order Allow,Deny
Allow from all

Restart your web server. Now just find out what’s your current public IP address and try to go to:

http://<public IP address>:<port>/

i.e.:

http://13.37.223.21:8080/

It should work now! … Or, at least, it worked for me.

Problems? Thoughts? As always, feel free to leave a comment.

Last update:

View this page on GitHub