How to run Plesk on your local network and access virtual domains on your Mac

- by

Plesk-LogoWhether you’re running Plesk on a dedicated machine on your network or in a virtual environment, you’ll want to setup test domains and work with them as if they were live – just like it was running in a data centre. It’s not as easy as I thought, which is why I took some notes on how to do it.

In this example I’ve got a dedicated CentOS instance on my local network. This can be my trusty old NC10 netbook, or a virtual machine running on Parallels Desktop on your Mac (I’ve explained how to set this up here: https://wpguru.co.uk/2014/02/how-to-ssh-into-a-virtual-machine-in-parallels-desktop/).

Plesk is already installed and ready to rock – all I need is a way to gain web access and setup domains that need to resolve properly. Out of the box all I get is a blank screen when I access the Plesk GUI using https://11.22.33.44:8443 or http://11.22.33.44. Let’s fix this.

Preparing CentOS to accept web requests

Thanks to Ivan from Parallels and Jamie from Urtechs for this tip: All we need to do here is to switch off iptables. Those are on and will filter many requests that look fishy and should be left running on a production server. Since I’m on my local network without evildoers attached, let’s switch it off:

service iptables stop
chkconfig iptables off

The second line will make it stick on subsequent boots we can use. You can easily switch it back on with the same command.

Tweaking your Mac’s hosts file

By default your Mac will reach out to its default DNS server to resolve domains. That’s how it finds which IP to connect with so that it can display websites. Plesk in turn would receive such a request and return the relevant website data.

To override your own local server’s IP address we can tweak /etc/hosts and define anything we like. For our example, I’d like example.com resolve to my own IP address (say 11.22.33.44). Here’s how I’d do that in a local Terminal session:

sudo vi /etc/hosts

This will request your Mac’s root password and show you a default configuration. Make sure you leave what you have in place and add the following lines to the bottom of this file:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

11.22.33.44       example.com
11.22.33.44       anotherdomain.com

Obviously replace 11.22.33.44 with the IP of your actual server. If you’re not familiar with vi: hit “a” to enter edit mode, hit “esc” to stop editing and enter “SHIFT Z Z” to save the file.

Now make your Mac reload this configuration with the following command:

dscacheutil -flushcache

Thanks to Manski for this tip – read his detailed article here.

Now when you try to visit http://example.com it will resolve to your local server and display the Plesk default page. Test this by pinging the domain in the terminal session – it should return your server’s IP. You can add as many of your own domains as you like to the bottom of this file, including other IP addresses for other servers on your network.

There’s a handy tool called Hostbuddy which makes editing and flushing the file a breeze – check it out:

Setup a domain in Plesk and enjoy

All that remains is to setup example.com as a domain in Plesk and install some content – as if it was a real server on the real internet. You can now test websites with the power of Plesk without having to buy real server resources.

Troubleshooting

If a domain exists in the real world (like example.com) your tweaked configuration will override this and display your server instead. However, if your server isn’t running, or the IP has changed then you’ll receive a blank page instead. Check with ifconfig what your IP address is and tweak /etc/hosts accordingly.

If you only see the Plesk default page make sure your subscription is setup to point at the correct IP address.

Make sure that your URL is correct: since NGINX automatic redirects are no longer working. You must specify exactly what you’d like to access (such as “http://test.test” rather than “test.test”)

Have fun šŸ˜‰



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.