CloudWays Hosting: Migrating my site from Linode VPS

A few months back I moved my site from a Linode VPS, over to Cloudways. In this article I cover how it went, what was good and what was bad.

Introduction

A few months ago I decided to move away from Linode VPS instance over to CloudWays. If you recall my previous blog post from a few years back I moved the hosting of this site over to a Linode VPS. My reasoning behind this is to allow me to try and focus more on building websites instead of managing the server. Whilst this site is small and the server only required a small bit of debugging I decided to give up the extra freedom a custom server offered in favour of a simpler, less time consuming solution.

Why I decided to Move

As touched on in the above paragraph I wanted to focus more on building websites, apps and creating more content for this blog. Whilst I could have left the other server with unattended upgrades and left it at that. I was drawn more towards another solution which wasn’t too expensive but the platform gave me a few extra features.

With a young family I no longer found the time or interest to start tweaking configuration files and managing package updates and server upgrades.

Why Cloudways?

Cloudways seemed like a pretty good solution and what sold it was the backup and restore functionality as well as the performance benefits provided by using Varnish etc right out of the box. I’ve been tinkering with servers since I started my first agency job back in 2012 and whilst I enjoyed it back then, it’s just not something that excites me as much at the moment.

I’ve heard great things from others about how easy Cloudways is to get up and running and having that extra live chat support when trying to fix issues is really helpful.

Conclusion: How is CloudWays?

After using Cloudways for a few months I can happily say that I haven’t had any hiccups at all with the service. There have been a few teething problems but this will be the case when moving from a VPS over to a more restrictive, managed solution.

Setting up MailHog on Mac and configuring to run with PHP

Introduction

Whilst developing a website it’s nice to have that extra piece of mind that emails won’t be sent out to clients or customers. I think a perfect tool for doing this is MailHog.

In a previous article I spoke about getting Mailcatcher setup which is another alternative to Mailhog. The functionality you get out of it is pretty much identical however people may prefer one over the other.

Installing MailHog

In these instructions I am assuming you already have PHP and brew installed on your mac. If you don’t you can follow this comprehensive guide to get them both installed.

Once that has been done already you can run the following commands:

These update the package list for brew, install the MailHog too and set it up to run.

Once done, visit this url to check it’s working: http://0.0.0.0:8025/

Setup MHSendmail ready to use with PHP

Next we need to install a tool known as mhsendmail. This is a dropin replacement for the sendmail command in PHP and makes the setup of Mailhog much smoother.

First off mhsendmail tool is built on top of go so if you don’t already have it installed you can install it with the below command or download it manually from these instructions:

Then get the package for mhsendmail using a go get command:

Setup sendmail path

In order to link the mhsendmail command to PHP we need to locate our php.ini file. If you have installed PHP using brew the path will be:

If this is not the case you can locate it using the following command:

After which you should see the following output containing the path to PHP’s ini file:

Once you have found the file you can edit it with your command line text editor (I prefer vi however other options are available).

Find the line for sendmail path (it likely will be commented out if you haven’t touched it before) and edit it to point the following:

Once you have done this be sure to restart PHP using the following command:

You can copy and paste the below PHP script to see whether or not it is working:

You can then run the script from the command line:

After doing that you should then be able to see the email in mailhog at this url: http://0.0.0.0:8025/

Setup mailhog to start on boot

When starting up my mac I like to know that all services I need are booted up and working correctly. In order to setup booting software on startup you can use the following command to link mailhog into it.

Whilst doing this I did encounter the following issue:

In order to resolve this, you can do the following:

Conclusion

After following the above steps you should now have Mailhog working within PHP on your local environment. Feel free to reach out with any questions in the comments and I’ll do my best to help.

Great tools for Website and online Developers

In this post I discuss some of the tools I have used in the past and currently use today for organisation purposes.

At the moment, with the massive rise in open source projects there are so many great tools for developers. This post will outline the tools I use to help make my development life much easier.

GOGS

Gogs Logo (site tools)

For git repositories, GoGits (GoGs) is a great self hosted tool. GoGits is heavily influenced by Github in both its design and functionality. The way I use it is for hosting projects any projects which I may need to access elsewhere. At the moment I am primarily using it to test out new things and host a big range of projects that I can pick up when the mood strikes.

Built with Go, GoGits is an extra dependency to install on the server. Having multiple sites on one server I run it behind Apache which handles the SSL and means all my sites are configured in a similar way. I’m sure that GoGs offers all the functionality of having it be setup without the need for Apache. Maybe that’s something for me to add to my trello list.

Why not Github?

For a regular user like me I think that GoGs is probably a bit of an overkill as I don’t use half of the functionality it ships with. Having the ability to easily setup new repositories and just code though is great and incredibly useful. People probably are asking the question “Why don’t you just do it on GitHub?”. Three reasons:

  1. I use GoGs for testing and throwaway projects most of the time, so might not necessarily want them to be seen.
  2. I get the flexibility of everything been in one place where I can just share or make repos private without needing to worry about costs or another companies licences (Microsoft is coming!).
  3. The experience. It’s great to have something like this on a CV as it shows interest and are passion for the web and server configuration.

All in all I think GoGs is an awesome tool and if you feel like taking advantage of any of the benefits I mentioned above I’d recommend giving it a shot.

Trello

Trello Logo (Site Tools)

I mostly use Trello at the moment for a single massive board where I have a big list of things I want to learn and build. Trello makes it easy to just quickly note down any thoughts you may have wherever you are and everything always keeps in sync. It’s free and I’d definitely recommend it.

Personal Website

Wordpress Logo (Site Tools)

I first had the idea whilst looking for a new job to have a blog. Somewhere I could record my thoughts and share some of the things I have discovered with others. The site holds most of my CV and a few other blog posts which you may find interesting.

The site also allows me to document my ideas and give me something to look back to. The foundation for the site is currently WordPress just using the twenty seventeen theme. I did build it with the thought of building my own theme and learn a bit about plugins. Other things have however got in the way, as they often do so that part is on halt for the moment.

MediaWiki

MediaWiki (Site Tools)

I setup my own wiki which I would recommend to anyone. It runs on MediaWiki, a free to use PHP based Wiki site. I primarily use it to document anything I feel I may need to check/do repeatedly in the future. A great example of this is simple commands to refresh SSL certificates and various configuration examples from different frameworks. This helps greatly in keeping things documented and in a safe place where I know I can find them.

Conclusion

This concludes some of the main tools I am using on a daily basis, the majority of which are to help with project management and planning. I’m keen in future to share some of the tools which I use for development in a future post.

Talk soon!

Mailcatcher setup for PHP on Mac OSX

In this post I will be walking you through the process of setting up Mailcatcher on for PHP on MacOS.

In this post I’m going to talk about installing Mailcatcher for PHP on Mac OSX.  It is particularly useful when developing new websites as you can test emails without worrying if they are going out to a recipient.

This has two advantages:

  1. You can rapidly test emails without worrying that it will go out to it’s recipient
  2. You can save money on services such as postmark or mailchimp since development emails no longer will hit that service.

Installing Mailcatcher

Mac’s come preinstalled with Ruby so it’s as simple as installing a ruby gem. This is just a package manager which allows you to easily install programs and libraries. To install mailcatcher simply run the following.

Let it do it’s thing which will involve installed any dependencies for mailcatcher and finish setting up.

One completed successfully you can run the following:

If the program started successfully you will get the following:

If you open http://127.0.0.1:1080 you will be presented with the mailcatcher interface.

Screenshot of Mailcatcher interface

That’s the first part and mailcatcher is now setup for the mac. Next we need to link it with php, which is covered in the next section.

Setting Mailcatcher up with PHP

Once this has been setup we now need to link it to PHP.

First we need to find out where catchmail (a program installed with mailcatcher) has installed to. I’m going to assume it’ll be located in the following directory:

However if you are unsure you can run the following command:

This will return the directory path for catchmail. We will need this later.

Next we need to find the php.ini file so that we can configure catchmail to respond to the mail() command in php. You can find this by running

And finding the configuration file path function. e.g.

Once found open up the file using your favourite command line text editor:

Update the following:

to

And update:

to

Once the above has been done save the file and quit out.

Restart php locally and try to send a test email using the mail() command.

If you open up the following url: http://127.0.0.1:1080

You should now see your email going into Mailcatcher.

Congratulations you now have a working setup for testing development emails. Good job!

New job and a recent Server Migration

After starting a new job I have been getting used to the adjustment. I have also done a server migration from Digital Ocean over to Linode.

Server Migration

It’s been a while since my last update. After starting a new job I have been getting used to the adjustment. Last night I managed to find a bit of time to get some things in order which have played on my mind for the past few months. I have since done a server migration and moved my site hosting to Linode. This has allowed the doubling of available RAM on the server to improve performance for roughly the same price.

Linode Logo - Company used after my Server Migration

This has allowed me to setup the hosting of a private mail server. Something which I have been looking to try for a few years now. I’m looking forward to tweaking this and seeing what it’s capable of. The changes had brought this site down for the past 24 hours so that I can reprocess the SSL. I might look into this further to prevent downtime in the future and maybe write a quick post in future to share how.

Whilst doing the server migration and upon building the new mail server I encountered a fairly large issue. This issue caused the server to constantly stay at 100% CPU usage whilst my spam blocker service ran. After an hour of head scratching and confusion I managed to figure out that it was a configuration issue. This was due to the user an out of date configuration setup tutorial.

Not long until I’ll be a Dad!

I have also been busy preparing for the arrival of my first child. It’s pretty amazing how much such a small person in life would require at such a young age. The due date is tomorrow and I am getting anxious and very much looking forward to meeting him/her.

Between the end of march and beginning of May I attended NCT classes. These were recommended by most people I spoke to and have really helped in preparation. I’d definitely recommend them also to any new parents as they will teach you vital things going forward. As strange as it sound I think it helped the experience to sink in a little more and feel more ‘real’.

I’ve also picked up a couple of parenting books. One I would definitely recommend to new Dad’s is “The Expectant Dad’s Survival Guide” by Rob Kemp. It’s been full of seemingly great knowledge and shares experiences about the topics from other Dad’s.

Until Next Time