Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring external access to XAMPP

I use XAMPP to develop wordpress themes, and I want to use ManageWP to administer / clone the sites to the production server. I have followed every tutorial I can find on the matter, but can't manage to get external access to my localhost!

This related SE answer seems so straightforward!

  1. Configure the web server to listen on your external network interface (Apache is often configured to only listen on localhost by default).
  2. Open port 80 for inbound connections in the firewall on your computer.
  3. If you want people outside your LAN to access your server, enable port forwarding in your router/gateway, so that port 80 is forwarded to your computer.
  4. If you use DHCP in your network, configure your DHCP server to give your computer the same address every time (for example, by MAC address).

I'm pretty sure I've got the last three steps right, (no firewall, ports 80 TCP&UDP > 80, server IP assigned by MAC address) but I don't know how to do the first (I've tried playing around in httpd.conf by setting the ServerName to my external IP address, but thats just a wild random fail :)

Whilst port forwarding is active I can see the website at: ##.###.64.188/mysite.dev (my external IP) whilst I'm on the local network, but if I connect via my 3g mobile connection i get:

Not Found
The requested URL http://<snip> was not found on this server
Apache Server at ##.###.64.188 Port 3128

which seems to indicate i'm somewhere in the right vicinity! but no idea where to go from here...

Any suggestions? TIA, Tim

Running:

  • XAMPP v1.7.3
  • Mac OSX 10.7.4
like image 987
ptim Avatar asked Jun 05 '12 17:06

ptim


1 Answers

Simple answer here: my ISP Optus blocks incoming connections on port 80. So, I've added:

listen 8080

to httpd.conf and adjusted my port forward correspondingly, and now i connect fine!

For those coming after, I've also setup http auth directives in my ~/Sites and /phpmyadmin entries in httpd.conf for somewhat increased security.

To get the WP site and links working, I'm setting the WP_SITEURL dynamically:

// wp-config.php
$host = $_SERVER['SERVER_NAME'];
if($host == 'subdomain.mysite.com')
    $url = 'http://subdomain.mysite.com:8080';
else
     $url = 'http://mysite.dev';

define('WP_HOME', $url);
define('WP_SITEURL', $url);

Then, in the virtualhost for the site I'm configuring, I've set <VirtualHost *:8080>.. works a treat! mission accomplished.

(Edit: I no longer have XAMPP installed, and have forgotten its directory structure, but the virtual hosts are defined similarly to the apache2 default: extra/httpd-vhosts.conf, which is included towards the end of httpd.conf)

PS manageWP needs to be whitelisted to allow connections past the http basic auth.

Big thanks to Garth and River who answered my call on FB...

like image 116
ptim Avatar answered Sep 19 '22 12:09

ptim