Tag Archives: macOS

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

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:

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:

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:

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:

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 😉

How to display wired clients on an Apple AirPort Time Capsule

Version 6.x of Apple’s AirPort Utility displays all your wireless client’s IP addresses, but it doesn’t show you wired devices. The old version 5.6 did, but without a hack it no longer runs on Mountain Lion.

There is however a simple way to display all clients using the command line tool arp. Open up a Terminal Window (Applications – Utilities – Terminal) and type the following:

It’s not pretty, but it gives you a good idea of what’s attached, and which IP addresses to try. You can also compare your wireless devices to this list and see which one is the “odd one out”.

To display your wireless device IPs, open AirPort Utility, then option-double-click onto your AirPort model/icon and a window opens up. Each device has “friendly name” and a small triangle that will display its IP and MAC address:

Screen Shot 2014-02-05 at 13.06.38

How to add links and images to your Email Signature in Mac Mail

mail-iconOne of the worst features ever about Mac Mail is the way it handles email signatures. For a feature so basic, something so ultra super simple, it has to be the most unintuitive thing ever about Mac OS X.

It gives me the rage every time I have to set this up, so perhaps these notes will help me and you when we’re faced with this dilemma again: setting up new Email Signatures in Mac Mail.

Creating Signatures

Open Mac Mail, then head over to Mail – Preferences. Click the Signaures tab and you’re presented with a list of your email accounts on the left, a list of signatures in the middle, and the actual Signature Preview on the right, much like this:

Screen Shot 2013-11-07 at 12.01.53

You may have been asking yourself “How the hell can I associate one signature with an email account”, and the simple answer is “drag and drop”. But we’re getting ahead of ourselves here. Let’s stick with making a signature look ravishing first.

Add new signatures with the plus button under the middle column, and delete them using the minus icon. This part makes sense. None of what follows does – at least not to me.

You can add text in the field on the left with any of the signatures selected. However, everything will be “Helvetica 12, black, no HTML”. That’s not necessarily what we want.

Styling your Signatures

The built-in option lets you add custom fonts and colours, simply by using the Format menu item, just like you would when you style text in your emails. Who would have known this would apply to signatures as well, ey? Format – Show Fonts and Show Colors brings up those ugly floating pallets. Highlight some text, apply your styling, and off you go.

But how about a link to your website? Can you apply a URL or any other HTML?

Well not exactly… unless we use a workaround.

Adding URLs and HTML

This is a hack, but works – thanks to an article on about.com for the tip.

Basically you have to write out your HTML in a text editor or use a code editor like Dreamweaver, then save your file (anything like your-signature.html should do). Open this file in Safari, then select all in Safari, copy, and paste it into the Email Signature Text Field.

I know. Don’t ask. It’s a little bit “un-Apple”, but it works – that’s all I need to know.

You’ll notice that all your text will be styled as Times and look super ugly – but the good news is that you can just mark it and apply the styling as described above. At least we’re getting somewhere now.

Still no images though, unless you link them in your HTML. Let’s see how we can add those next.

Adding Images

This is perplexingly easy: open a Finder window and navigate to an image you’d like to use. Then just drag it from the Finder window directly into the Signature Field and let go.

Fascinating, isn’t it? How this ends up in my recipients inboxes is a puzzle. It works, that’s all I want to know.

With our signature complete, how do we make it appear when sending an email from a selected mail account?

Associating Signatures with Email Accounts

There are several steps to this process. Remember that list of email accounts on the left of the above screenshot? Find your desired account in the list on the left, select your signature in the middle column and then drag it onto the email account you want to use it with. You’re not finished yet though.

Next click on the email account on the left and find a “Choose Signature” drop down menu at the bottom with several options to select from. By default this reads “None” and it means that when you send an email from this account, no signature is displayed.

Select the desired signature from the menu or choose from “At Random” or “In Sequential Order”. You’ve guessed it: you can add more than one signature to an email account, perhaps with different funny jokes or advertising slogans. A neat feature! With these two options you’d send your emails with a different signature every time.

Screen Shot 2013-11-07 at 12.24.45

You can also choose if you’d like to display your signature above or below quoted text. I like to tick that box, because I’d like to appear my sig below what I write, and above what I’m replying to.

Close the window and write an email – you should now see your hand crafted graphically beautiful signature at the bottom of your emails.

How to remove __MACOSX from zip archives

Creating a ZIP file on your Mac is really easy: select a few files in Finder, right-click on those and select “Compress…”. It’s the equivalent of selecting “Send to ZIP Folder” under Windows.

But Mac OSX does something rather bizarre when creating ZIP files: it adds several unnecessary, unwanted and un-called-for files starting with __MACOSX. This drives PC users nuts – and believe me, it drives Mac users nuts too.

Thankfully there is a relatively easy way to remove those files. This may not always be necessary, but if you require a “clean” ZIP file, here’s what you can do.

First, create your ZIP via the finder – like you always do. Next, open Terminal and cd into the directory where your ZIP file is located. If it’s a long path, just type “cd “, then drag the folder into Terminal (less typing is always good).

Now type the following:

And that should do it. This command (zip) will remove everything (-d) starting with __MACOSX from your ZIP file (your-archive.zip).

To verify, type the following:

This will simply list the contents of your-archive.zip.

Alternatively there is a utility called YemuZip: http://www.yellowmug.com/yemuzip/

Or just use a PC 😉

Workaround: Parallels Desktop is not seeing my DVD Drive in Mountain Lion

Today I wanted to install Windows 7 using Parallels Desktop 7 on my Mac, but sadly I always got an error message every time I tried. It was saying it could not connect to my DVD drive – which clearly my Mac could.

Doing some research it turns out that several people had this problem, however I didn’t understand the instructions given by Parallels very well. Getting frustrated I decided to write my own, and give you some pointers where else to look for help.

For this scenario I’m using a DVD copy of Windows 7 Home Premium and the latest version of Parallels Desktop 7.0.15107. Parallels Desktop 8 is already out but I’ve decided not to upgrade at this point.

Continue reading Workaround: Parallels Desktop is not seeing my DVD Drive in Mountain Lion