Some notes about Digital Ocean servers

I’ve been unhappy with my current website host. My old hosting company, Verio, sold part of its webhosting business (including my websites) to another company. Verio used to provide php by default. The new host does not. I decided to try out another cloud provider, Digital Ocean, to see what they can provide.

I spent a while reviewing their help pages to prepare myself for surprises. I spent enough time on their documents site that they gave me a $10 credit when I set up a new account. Eventually, I set up an account with them and received the credit. Click on the link above to get your own $10 credit. (I’ll get some credit, too.)

Setting up a droplet is just as described in their setup page. It’s almost exactly the same. Digital Ocean provides more machine size options ($320/month and above) for monster machines with dedicated CPUs and/or high RAM requirements. I don’t need that. I want a small Ubuntu machine that I can use to hold the domain names that I have and don’t use.

I like their suggestion to use public/private keys. I did not realize that each machine should use exactly one key pair. I had set up key pairs for Bitbucket, Github and now Digital Ocean. I was unable to log in automatically with the key pair until I replaced the public key with the default public key I created on my machines a long time ago. I still set up a password for the non-root account. I still have to key it in for ‘sudo’ stuff, which is annoying, but login works automatically and well.

I decided to follow their instructions for setting up a server firewall. I’m not familiar with IP tables and Digital Ocean recommends using ufw. I followed their instructions and discovered that new terminal windows were not logging in automatically with ssh. It kept timing out for some reason. I rolled back my ufw changes, but I still had trouble with logins. I sent in a help ticket and received some additional instructions that look like they work. They have so far, so that’s good.

I continued setting up the server. Apache installed without trouble, even though they recommend Nginx. (I don’t know Nginx yet.) I skipped MySQL because I did not need it for a placeholder / testing site. I followed their instructions for installing PHP and … discovered that Ubuntu 16.04 does not have default repositories for PHP5. It has repos for PHP7. I had to add an additional repo for the PHP 5 files. Not a big deal, once I knew what was going on. Finally, I have PHP5 installed on the placeholder site. For a placeholder site, I like it.

Advertisements

Python errors: I should have known that

I needed to write some data to a MySQL database. I set up the MySQL Python connector without any real trouble. I tested it in a tiny Python page and it does connect to the correct database. Great!

I moved the connection code to a function on a new page and ran into trouble. I kept seeing a message saying something about “Reference error: weakly-referenced object no longer exists”. After a detour into weak references, I realized the issue was garbage collecting. Somewhere within my function, I had a object that was disappearing.

The connection function had no parameters. A connection object local to the function was created and the resulting cursor was returned. You should see the problem immediately. The connection object what the item that was disappearing. I rewrote the function to send back the connection object and then extract the cursor from the returned object. That error message went away.

I had another strange problem where updating a field was not allowed because of a type mismatch. I’m used to PHP, where weak or loose types are the norm. Once I realized that data going into the MySQL table also needs to match the correct type expected by the MySQL column, my problem is solved.