Hosting Horrors Part 2

Hosting Horrors Part 2

Time to get back to it, hosting your sites that is. Unless you’re reading through the archives. In which case it was just time to click on the link for the next link. Kind of gets rid of the anticipation though doesn’t it?

Setting up your VPS instance

Sign up for Digital Ocean, and then create a droplet. The instructions I’m going to be giving you are for Ubuntu 14.04 LTS. You can use something else instead, but I like Ubuntu quite a lot, your mileage may vary.

There is a great walkthrough I used on Digital Oceans support site here There are a couple of things that I would say though if you are going to be going through this whole walkthrough and using Easy Engine. My first thought when I install a new Linux server is to install MySQL and Apache. You aren’t going to be using Apache and it was a pain to migrate off of it, so I’d recommend against installing it now. Also don’t install MySQL yet unless you have a specific reason to. Let Easy Engine do it and you can save yourself creating a couple of config files and such. It’ll set a random root password that you can change later if you want. It boils down to just setting up your users, specifically one with sudo access. I also usually set my root password in general when I do a new install. You do that by doing the following:

sudo su

Enter in your password then put in

passwd

Set the password and now your root user has a password set. If you want to do a whole lot of root stuff this can be a nice thing. Just realize that you’re going around all of the security that Ubuntu puts in to keep a static root user out. There are occasions when it can be really nice though so just be aware of what you’re doing.

Also make sure that you have openssh-server installed. Make sure that you can SSH into the box. Once you have the DNS setup you can just use user@yourdomain.com where “user” is your username and “domain.com” is any of the domains you pointed at the instance.

Easy Engine

Easy Engine is a piece of software that makes setting up your server infinitely easier. You have to get your VPS setup first though as we went through before. The install process at Easy Engine is pretty good and I’d recommend it. It is basically just running a shell script as root. It allows all of your stack to be installed by Easy Engine.

After that I would recommend running

sudo ee stack install --all

That will install anything that isn’t already installed. Also run

sudo ee stack install -php7

That will allow you to run sites in PHP7 mode. It’s super fast, although a lot of older plugins and themes don’t support it. I tried it out on a clients beta site and the landing page loaded super fast, but it wouldn’t go to any other page. I put it back since I could see them wanting their customers to be able to navigate their site. It’s always something with those people, right?

Creating a site with Easy Engine

Creating a site with Easy Engine is pretty easy. As long as you have your DNS updated and it’s propagated out you can go off to the races.

sudo ee site create yourdomain.com --wpfc --letsencrypt

So lets break that down a bit.

sudo ee site create yourdomain.com

That creates a new site. One of the most basic forms of that is

sudo ee site create yourdomain.com --wp

That creates the site with WordPress. It creates a MySQL database and a user for that database. It installs the newest version of WordPress and then creates a user for you. You can specify that in the config file, but if not it will tell you the login details in the terminal session. I make sure to set my default user as the same email address as my wordpress.com account then I can install Jetpack and enable Single Sign On, and I’m off to the races.

The next part is the

--wpfc

That installs the Nginx cache options for WordPress. There are some faster caching stuff out there, but that enables Memcache and some other goodies. It also tends to just work and I can’t be bothered to mess with my caching options all day long. I’ve tried thw w3tc option (wwwtc super cache) and I’ve had tons of issues getting it to stay working. It’s always something with my .htaccess file. I also make sure to enable the image CDN stuff in Jetpack. If you select jump start when you install it you’ll be good on that. It enables it that way.

The last part is

--letsencrypt

That enables a free SSL cert on it. That’s why I had you create a www A record in your DNS earlier. Lets Encrypt checks for that. It will make a SSL cert for 90 days, but it will also create a cron job that renews it 30 days before it expires for every site you use it on. Pretty cool right? I thought it was. It saved me a ton on SSL certs.

Final Hosting Steps

So your site is installed? Great! Now go to https://yourdomain.com/wp-admin, login, then you’re good to go. I’d recommend installing Jetpack in the plugins section (it’s one of the top featured ones, can’t miss it), activate it, tie it to your wordpress.com account (create one if you don’t have one, they’re free), and click jump start. I also enable monitor on all of my sites so that I get an email if they go down. I also do a couple of other things on all of my new sites, but I’ve already been running pretty long on this. If people are interested I’ll go into my next steps. They’re Google Analytics setup, Google Webmaster Tools, and some email forwarding stuff on the server. Also some WordPress best practices (backup, SEO, Security).

Conclusion

Now you have a functioning web server. Pretty cool right? Now you just have to administer, update, and take care of it (that’s the easy part right?). Do you have a better way of running your web server? Let me know in the comments. Do you have any questions? Let me know in the same place. That’s actually just going to be a good generalization. Correspond in the comments. Yeah, lets go with that.

Hosting Horrors Part 1

Hosting Horrors Part 1

I started hosting all of my own websites on VPS instances in the cloud. I was sick of the price and quality of hosting in general. I was on a shared hosting plan, like most people that administer their own sites. It was fine when I was just hosting my website, which was really just a place to put my resume and my PGP key. I’ve had that domain for years and use it as my primary professional email domain. I lucked out and got in before Google started charging for a few emails and I’m grandfathered in.

Once I started hosting sites for clients it got to be a bigger issue. The latency and uptime was all over the place. My sites were going down every week. The hosting provider tried to say that they didn’t go down, they just didn’t respond for a while, which seems like an academic distinction to me. Unresponsive is unresponsive. I then migrated all of my sites to a VPS provider. It was pretty good, but I didn’t realize that they were, “Managed,” VPS instances. That means that you don’t have root access, it’s really just shared hosting with less bells and whistles. However the performance was MUCH better. I couldn’t do any of the server optimizations that I really wanted to though. What if I don’t like the compression extensions they’re using? Heck, what if I don’t want to use Apache for a web server? Get a dedicated server was the response from their documentation. I’ve been system administrator on some dedicated servers and I’ll pass. They’re also really expensive. If I need that kind of performance I’d prefer to load balance multiple servers so that I have HA (high availability) and fail-over. Although load balancing your load balancer is an interesting problem. If you want that kind of fault-tolerance with dedicated servers you’re also paying for MULTIPLE dedicated servers which is even more expensive.

After all of that I moved to an awesome service called Digital Ocean. I’ve been with them for a while and I use a similar service in Australia called Binary Lane.

Domain Registration

So with Digital Ocean I started hosting all of my sites. I also migrated all of my domains off of my previous hosting provider to a DNS only service. Digital Ocean doesn’t do domain registration which is good, because it forced me to move my domains to a domain registrar that only does that. It’s a good move, because then if you move from one hosting provider to another you don’t have to pay to re-register your domains. I was out over $100USD this year before I realized that. I use Hover, and highly recommend them. They even helped me with transferring/registering some .com.au addresses, and that is an extreme pain. Did you know you need basically an Australian Social Security Number (ABN) to register a .com.au domain? It’s a pain.

DNS Hosting Settings

So DNS is a bit of a black art in a lot of tech. A lot of people say they know DNS and what they really mean is they know the difference between an A record and an MX record, or they know that DNS translates IP’s into human readable URL’s. The core of DNS is simple, but the ways it interacts is not. Also kudos to anyone running a DNS server is a pain. It’s not too bad on Windows, but the O’reilly book on BIND (the major Linux based DNS server) is huge. I got asked in the early stages of my carer to start running a server for the company, and I agreed (because I was an intern and wanted to please). I looked into it and was floored. Fortunately the company wasn’t great on keeping track of it’s ideas so it died a slow death.

Later on in my career, pretty recently actually, I worked on a product that intimately used DNS. The new standards that doctors and hospitals use to communicate with each other and patients use DNS as an authentication layer. It uses DNS cert requests to verify PKI (public key infrastructure). A couple of my colleagues and I looked through a whole lot of DNS routing stuff before we got a handle on exactly what the order was. For instance if I go to a subdomain for a domain does it query the NS record before the A record? It seems like a subtle difference, but depending on that it can go to an entirely different server that doesn’t have the records you need to resolve. We developed a joke that when stuff didn’t work you’d just say, “I don’t know, maybe it’s the DNS?” Now we’re going to go over how to set your DNS settings for your hosting from your registrar then set the other settings on your host.

So in order to host your sites at Digital Ocean and have your domain registration with Hover then you’re going to need to change your name servers for hover. You can set them in the domain settings. You need to change them to the following:

ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com

Then you’re going to need to change the DNS settings on your Digital Ocean account. You can do this by navigating to networking along the top, then going to networking. Then you can select domains. Add the domain that you have. then go into it. You’re going to want to set an A record for both

@.yourdomain.com

and

www.yourdomain.com

I’d also create an A record for

mail.yourdomain.com

and then create an mx record for

mail.yourdomain.com

You should see the IP for your droplet get entered into your records. Set all the A records to that IP. You can also request a floating IP and use that as well. I just used the one that was included. If you can’t find it then SSH into your VPS and run

ifconfig

That should give you the IP (it’s not the loopback one).

Your DNS should work now. You can verify by running nslookup on your machine (if you’re Windows). However for the purposes of this I’ll just recommend using an online service. A good DNS server to check against is 8.8.8.8. That’s Google’s DNS and they’re pretty good. I also sometimes use 4.2.2.2 which is Verizon.

That concludes Part 1. Next time I’ll go over getting your VPS and the management layer of your server set up. What, you can’t wait for the next part? TOO BAD! BWAH HA HA HA!!! Sorry, but these walk-throughs get super long, so I’m splitting them up. If people hate that let me know in the comments. It seems like a few thousand words in a row is excessive, but what do I know?