Nathan Wailes - Blog - GitHub - LinkedIn - Patreon - Reddit - Stack Overflow - Twitter - YouTube
Cloud hosting / VPSes / Digital Ocean / PaaS / Dokku
Table of contents
- 1.1 Table of contents
- 1.2 Child pages
- 1.3 Related pages
- 2 VPS Providers
- 3 Topics
- 4 Dokku
- 4.1 Troubleshooting
Child pages
Related pages
...
VPS Providers
1&1 / 1and1
How to set up Filezilla for FTP into 1&1
Follow the instructions here:Â 1&1 - Configure FileZilla with the 1&1 Configuration File
Once you connect with Filezilla, it'll ask you for a password. It's in LastPass as "1and1 SFTP (w/ Filezilla)".
Misc
1&1 does not offer a $1/month permanent plan. The guy I spoke with said that the cheapest plan typically works out to ~$130/yr.
Â
Digital Ocean
Things to be aware of
When you paste in an SSH key, the whole thing needs to be on one line, and it needs to start "ssh-rsa" and then a space and then the key itself, with no other surrounding text. So the default formatting you'll see in your SSH key file will not work, and they won't validate it to let you know that there's something wrong with it.
Tutorials I used to get Rhymecraft working on a DigitalOcean droplet
I used this to install Python and the other Linux programs it says are good to have when working with Python. I didn't end up using parts 2 and 3, which discuss how to set up a virtualenv and create an example Python program.
I used this to set Python3 to the default Python version, to install pip, install MySQL, install Apache, and set up the Apache config for Rhymecraft. I skipped the last part, which shows you how to create a simple example program to test that MySQL and Python can work together.
2013.07.03 - DigitalOcean - How To Deploy a Flask Application on an Ubuntu VPS
I used this to install mod_wsgi, to configure and enable a new Virtual Host, and to create a wsgi file. I skipped steps 2 and 3 (on creating a sample app and installing Flask).
ReadTheDocs - virtualenvwrapper - Installation
I used this to install virtualenvwrapper, which got the "mkvirtualenv" and "workon" commands working, so I can (hopefully) use the sameÂ
update_server.sh
script that I'm using on PythonAnywhere (which uses the "workon" command).
2018.03.07 - DigitalOcean - How To Install Node.js on Ubuntu 16.04
I used this to install nvm, node, npm, and set the node/npm versions to the same versions I have on my laptop.
2012.10.13 - Graham Dumpleton - Why are you using embedded mode of mod_wsgi?
I used this to switch Apache from using embedded mode to daemon mode for my application, which is apparently the better way to serve Python web apps because Apache doesn't dynamically start and stop new Python processes (which has a performance overhead) but instead just keeps the same processes running.
I uninstalled the default mod_wsgi and instead installed it from within my venv by running
pip install mod_wsgi
.I then needed to run "
mod_wsgi-express module-config"
 (as described here) to output two config lines (seen below) that I then needed to put into thewsgi.load
file (path listed below), replacing the existing line that was in that file.File path:
/etc/apache2/mods-enabled/wsgi.load
Output of "
mod_wsgi-express module-config
"Â / new contents ofwsgi.load
:LoadModule wsgi_module "/home/nathan/.virtualenvs/rhymecraft/lib/python3.5/site-packages/mod_wsgi/server/mod_wsgi-py35.cpython-35m-x86_64-linux-gnu.so"
WSGIPythonHome "/home/nathan/.virtualenvs/rhymecraft"
I also had to:
upload some files required by the application that were not in the git repo (production.yaml, the background image)
add
encoding='utf-8'
 to a.readlines()
 call that was raising aUnicodeDecodeError
comment out two lines that enabled SSLify for my application, as I didn't have SSL set up yet and it was forcing my browser to use the https protocol to connect to the website.
2016.04.21 - DigitalOcean - How To Secure Apache with Let's Encrypt on Ubuntu 16.04
I used this guide to get SSL set up.
I hit an error when running the 'certbot' command that took me a long time to fix: "Name duplicates previous WSGI daemon definition".
The solution was to move the WSGIDaemonProcess and WSGIProcessGroup lines out of the <virtualhost:*80> tags to the top of the sites-available/rhymecraft.conf file, and then copy the entire <virtualhost></virtualhost> thing and paste it below, and then just change the "*:80" to ":*443" (for the SSL). (Source)
I had also turned off two SSL options in Cloudflare to get HTTP working, so I had to re-enable those to get the website to work.
2016.10.21 - DigitalOcean - How to Connect to a MySQL Server Remotely with MySQL Workbench
I used this guide to connect to the DO MySQL db from my local computer using MySQL Workbench.
Note that if you created a non-root user as recommended in one of the guides above for SSHing into the server, it seems you still need to connect as the user "root" here.
Note that MySQL Workbench asked me for two passwords when connecting. The first password was for the SSH private key file, even though I was running Pageant, and the second password was for the MySQL db.
MySQL Documentation - SQL Data Export and Import Wizard
I used this tutorial to export the database schema, tables, and data from PythonAnywhere.
Setting Up Cron Job Using crontab (pdf)
I used this tutorial to set up the generate_videos.sh cronjob.
GitHub - Connecting to GitHub with SSH
I followed these instructions to generate an SSH public/private key pair on the DigitalOcean server, so that I could add the public key to my Bitbucket account and then be able to do a git pull from Bitbucket.
AskUbuntu - Install ffmpeg in Ubuntu 12.04 LTS
I followed these instructions to install ffmpeg.
Errors and how to fix them
"Key invalid type"
When you upload an SSH key, you need to open the public key in Notepad and add "ssh-rsa" to the beginning of the key and the name(?) of the key at the end (e.g. "rsa-key-20171003", and then just copy the actual key (not the text above and below it) into the Digital Ocean box. (Source)
"Disconnected: No supported authentication methods available (server sent: publickey)"
I saw this when trying to ssh into the droplet as a non-root user with Putty.
The solution was to copy the authorized_keys file from the root user to the new user and set the read/write permissions.
That solution doesn't say where the existing SSH keys are stored. They're in
/root/.ssh/authorized_keys
 (that's a file, not a folder).
Topics
Serverless architectures
2016.08.04 - MartinFowler.com - Serverless Architectures
long, looks helpful
Cloud vs. co-location
Comparison of different cloud providers / VPSes
2016.11.18 - The HFT Guy - Google Cloud is 50% cheaper than AWS
2017.07.23 - Joshtronic - $5 Showdown: Linode vs. DigitalOcean vs. Amazon Lightsail vs. Vultr
2017.10.03 - HackerNoon - AWS vs. DigitalOcean: Which Cloud Server is Better
Â
Dokku
DNS
Set up two A records for each Dokku app: a "sub.domain.tld" record and a "*.sub.domain.tld" record.Â
I'm not sure what the wildcard record is for, I think it's for staging environments?
Networking
"By default, access and error logs are written for each app toÂ
/var/log/nginx/${APP}-access.log
 andÂ/var/log/nginx/${APP}-error.log
 respectively"
Â
Troubleshooting
I documented the trouble I had setting up Dokku here: https://github.com/dokku/dokku/issues/7118
Summary: I had to 1) reboot my droplet(?), 2) enable Cloudflare’s Proxy service to get HTTPS working, and 3) remove trailing slashes from my Go
AllowedOrigins
values.
Â
Â