The Quiet Musings

A Tale of Unix and a Web Server

- November 4th, 2017 -

Since I entered the world of coding in 2002, all I wanted was (still is) control. Control over my code, over my computer and over my website. I have no recollection how I stumbled upon weblogs like Zeldman, Kottke, Simplebits, etc. back in the golden days of weblogs. But once I found them there was no looking back. The first iteration of this weblog was made without tables, according to web standards with my own home-brewed PHP/mySQL CMS.

Back then Apple MacBooks or iBook and Powerbooks was quickly gaining popularity. I loved the fact that Apple uses Unix. I was always a Windows user and once I started coding with PHP in my free time, it became a pain for me. At college it was all Windows, IBM content management systems, ASP and a major headache to get things working smoothly on Windows.

Through my new online world, I read weblog posts about Apple computers, lusted after the nice apps, OS X interface and easy way to get things done with Unix. I kept dreaming on buying my own. Also, I was a college student renting a 3 by 4 room with no extra income.

Then I got my first internship, saved all my money and in February 2004 I bought my first Apple, a 12 inch iBook. Right away I also bought Learning Unix for Mac OS X Panther

It was a learning curve, but in no time I was sold and did not ever look back at Windows.

cd, ls, mkdir, chown, chmod, sudo, nano

By no means I’m a command line expert. I still forget longer commands and always have to look them up. Don’t even ask me to type a whole string of command. But I understand how the command line works, I can get things done with it, I have totally broken my OS installation once and recently I just setup a server on Digital Ocean.

What I learned in all these years using the Unix command line: Make sure you have time when starting a project like setting up a server. Expect things to break, don’t be afraid, back-up, back-up and back-up.

A whole day in command line mode

Almost two weeks ago I woke up really early to wait for people to come service my apartment. On a whim I decided to get an account on Digital Ocean and setup a droplet. I had been contemplating switching to a new server for months now. Once I started I got so sucked in. I did not leave my desk except to get food and stuff, until late night. I usually plan something like this in advance with a step by step plan. I obviously woke up crazy that day.

Digital Ocean

Digital Ocean droplet creations makes it easy to setup a droplet with WordPress. But remember, I woke up crazy and skipped the one-click-install tab and just created my droplet with Ubuntu 16.04 x32. At least I had the foresight of already knowing to choose the x32 version because I have the 512MB memory droplet and that’s a bit weak for running the x64 version.

Caddy, Apache, Let’s Encrypt, PHP7, mySQL

The thing I most wanted is SSL for my site. Like 10 years ago we all had the small web standard, XHTML, CSS badges. SSL is something you want, actually no: need, these days. I started reading the tutorials on web servers and Caddy was the first to come up. Completely unlike me I went ahead with it without doing research first except to figure the workaround for the binaries since Caddy went commercial. The install went smooth except for the delay while waiting for Leaseweb to change the name servers and then waiting for the DNS to propagate. I got my web server up and running with SSL just to realise: shit, I actually really prefer and need Apache2 because ain’t nobody got time to figure out all those .htaccess rules I currently have into Caddy. Let alone fighting WordPress penchant with using .htaccess and who knows what future app running in Apache.

Luckily I created an image of my droplet right after setting it up and the initial server setup. It was just a thing of restoring that image and starting over, but this time with Apache. I used that specific tutorial which makes it easier as far as I know, to create subdomains. Then I installed Let’s Encrypt. In between all that I installed PHP7 and mySQL. Those were the easiest to get done.

A lot of people are into deploying and me too. But most times I just want plain old FTP to just dump everything on the server and be done. Especially images, which I have a subdomain for. Plus, moving my WordPress installation from the old server to my droplet is far easier through FTP or in this case, SFTP. It was a bit of a head-scratcher, it wasn’t as easy as following this FTP instructions. Transmit, which I use, is an intuitive FTP client. But the thing that really stumps me every time in Unix are permissions. They are such a pain. Even days after being done I still had to mess with permissions because WordPress automated update failed due to permission issues.

PhpMyAdmin and WordPress

I installed PhpMyAdmin quickly and WordPress (with some php.ini edits) I did old skool manual way by downloading the core files, uploading them and running the install. Imported my database export from previous install, install all the plugins (while fixing more permissions) and done.

Also, a PHP7 thing: php.ini comes with short_open_tag standard disabled. I tend to use short tags in my templates, so I had to fix them all which is more sensible than enabling short tags.

All those years of setting up PHP on my Mac helped because things like Apache conf files and php.ini aren’t alien to me. Using nano to edit them is less intuitive, on my local setup I just use Atom. Nano slowed me down a bit.

10 days later

At the time of this writing this weblog has been up and running for 10 days with no problems so far. The only thing that completely broke and won’t work is my Mint stats app. I just get a blank page, no code, nothing. PHP error reporting returns nothing. It’s just dead, like the Mint app since Shaun discontinued it.

I have Google Analytics but if you ever used Mint you know how nice and easy it is. Just one page (mobile friendly) with all information, especially if it is a low traffic site. I tried Piwik but it’s also too big. I just want referrers, detailed location, popular pages, pages to watch and browsers/pc/mobile info in one oversight.

If anyone is an Analytics expert and know if you can customise Analytics for this let me know. Even better, if anyone knows why Mint won’t work (I suspect PHP7 incompatibility) let me know.

Besides that I’m happy with the results. I do realise that if my website goes down there won’t be a hosting company behind it to send a support ticket, it will be just me frantically trying to figure out the problem and then fixing it.

If you have any comments let me know at @Darice

Note 19/11/2017 After running the droplet for 25 days I discovered that Apache2 uses up almost all of the 512MB memory. I fixed the Apache conf file like shown in this post: How To Run WordPress on a DigitalOcean 512MB VPSĀ