While I was on vacation last week, I saw Marco Arment publish very thoughtful posts on the importance of relying on yourself for hosting services and content. That using many of the services, and platforms, out there can quickly wind up with large fees the developers are paying for relatively simple needs. There was also a side to it concerning proprietary services offered by these companies requiring custom code that basically locks you in to their service since you don’t want to have to rewrite all that custom code.
Newsflash: I am not a developer.
Breaking: I am interested in hosting my own “content”.
Exclusive: I decided to give it a whirl, as Marco suggested.
Besides, since the goal is to basically host this (gesticulates around the screen) stuff on a server, then the risk is super low. I mean, what does something like this really need any way? I would be satisfied serving static files.
My previous adventures in webhosting didn’t go well because I either pick a service where I have no options (I host my resume and demo reel site on Dynadot’s super-thrifty-guy plan), or I pick something where I have tons of options and no help (Nearly Free Speech). NFS had a huge learning curve because it comes set up in a very specific way, and uses BSD. Which doesn’t sound like a big deal, until you realize you (I) can’t even figure out how to install shit on the server.
I went with the inexpensive $5/mo. plan on DigitalOcean (referral link) that Marco had mentioned. It was easy to set up the VPS droplet. Populating it with exactly the data I want and securing it isn’t super seamless. (What do you mean I can’t just do everything in root?!)
I also tried their preconfigured LAMP stack (Linux, Apache, MySQL, PHP). Then I realized that was stupid because I don’t know anything about three of the things in the list. What I needed was Python, because I have a pretty decent understanding of Python through the work I’ve done.
So, using my new friend, SSH, I made a directory for the files, dumped the files over SFTP with Transmit, and then said, “I’m sure there’s a web server in the Python standard library.”
Spoiler Alert: There is a web server in the python standard library!
Spoiler Alert: The one in the standard library is not so great!
My first project, was to roll out (troll out?) prompt.photos, as a joke site. That would be simple, right? I’m serving 1 4KB html document I wrote by hand, with 4 PNG files. What could go wrong?
Things Went Wrong!
I simply restarted SimpleHTTPServer through ssh and it kept churning without an error (I kept checking on it). I went to sleep, and woke up at 3 AM. Sure enough, SimpleHTTPServer had SimpleSHITtheBed at 1 AM. I put it back up and then started looking on StackOverflow for a more permanent solution. SimpleHTTPServer module obviously wasn’t going to work. It wasn’t even a matter of configuring it differently.
Turns out, that looking in to Apache and Nginx serving static files at 1 AM is a headache inducing thing. Obviously, those two are the most vetted. Node.js fans LOVE their little node servers. Unfortunately, I must have done something wrong with my Node installation (both on my Mac with Homebrew and on the droplet). I nixed (get it?) that idea and went back to Python. I knew the interpreter was there, and that I had installed pip, so I theoretically had a wealth of well-tested packages I could download.
I went with Twisted. Now, if you know what I know (low barrier to entry), then you know that Twisted is a super-powerful, asynchronous, Python server (and other things). I had dismissed it precisely because I thought it would be like setting up Apache. (I basically didn’t want to edit any text files by hand last night).
Turns out, Twisted is insanely easy to deploy. You point it at a path to use as root, you run it as a daemon, and it does its thing. Compare this to Apache. Not only was it as simple to use as SimpleHTTPServer, but it was also faster, and (most importantly) it has not shit the bed. I will want to investigate another solution for serving multiple named domains from this host (since I’m not paying $5 for eternity to host a joke).
This is a tremendously helpful learning experience for me because I want to migrate (vogues your browser window) this whole thing off of Tumblr.
I had picked something easy, Tumblr, just to start writing and stop fretting over fiddly-bits. Just like SimpleHTTPServer, I wanted something that wasn’t fully featured so I wouldn’t go crazy. I sabotaged myself because Tumblr is borking my RSS feed now.
I contacted Tumblr support, and after the person told me all my posts were in my RSS feed, I convinced him they were not. He’s going to pass on my desire for a working RSS feed, but they have no plans to help me.
That’s cute! TOTES ADORBS, BRO!
Before someone helpfully points out that Tumblr is free, so I shouldn’t complain, I’d like to point out that it is advertising supported, I pay for it in eyeballs. I’ll also point out that it will be trivial to get off of their service now. I’ve said it before, but when they started getting all Yahoo(!) up in my biz, I was going to move. Hell, I’ll fucking scrape pages out of here with BeautifulSoup if I have to (I don’t have to). Pelican even has Tumblr export now.
I find this process enriching. Empowering, even.
I’m going to go all web-me-point-oh on this place. You hear me, Sid?
Most graphics software used to have proprietary scripting languages. That was impractical for the software vendors to maintain, and for the users to learn new scripting languages for each package. In the 2000’s, vendors all switched over to embedding Python, Lua, or TCL (pronounced TiCkLe). This is why I have a decent understanding of Python 2.7. ↩