Cloud hosting/computing/VPS providers / 1&1 / Digital Ocean / PythonAnywhere

Table of contents

Child pages

Related pages

  • ...

Providers

1&1 / 1and1

How to set up Filezilla for FTP into 1&1

  1. Follow the instructions here: 1&1 - Configure FileZilla with the 1&1 Configuration File
  2. 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

  1. 2017.12.20 - DigitalOcean - How To Install Python 3 and Set Up a Local Programming Environment on Ubuntu 16.04
    • 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.
  2. 2015.04.29 - DigitalOcean - How To Set Up an Apache, MySQL, and Python (LAMP) Server Without Frameworks on Ubuntu 14.04
    • 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.
  3. 2013.07.03 - DigitalOcean - How To Deploy a Flask Application on an Ubuntu VPS
    1. 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).
  4. 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).
  5. 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.
  6. 2012.10.13 - Graham Dumpleton - Why are you using embedded mode of mod_wsgi?
    1. 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.
  7. I uninstalled the default mod_wsgi and instead installed it from within my venv by running pip install mod_wsgi.
    1. 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 the wsgi.load file (path listed below), replacing the existing line that was in that file.
      1. File path:

        • /etc/apache2/mods-enabled/wsgi.load
      2. Output of "mod_wsgi-express module-config" / new contents of wsgi.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"
  8. I also had to:
    1. upload some files required by the application that were not in the git repo (production.yaml, the background image)
    2. add encoding='utf-8' to a .readlines() call that was raising a UnicodeDecodeError
    3. 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.
  9. 2016.04.21 - DigitalOcean - How To Secure Apache with Let's Encrypt on Ubuntu 16.04
    1. I used this guide to get SSL set up.
    2. I hit an error when running the 'certbot' command that took me a long time to fix: "Name duplicates previous WSGI daemon definition".
      1. 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)
    3. 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.
  10. 2016.10.21 - DigitalOcean - How to Connect to a MySQL Server Remotely with MySQL Workbench
    1. I used this guide to connect to the DO MySQL db from my local computer using MySQL Workbench.
    2. 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.
    3. 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.
  11. MySQL Documentation - SQL Data Export and Import Wizard
    1. I used this tutorial to export the database schema, tables, and data from PythonAnywhere.
  12. Setting Up Cron Job Using crontab (pdf)
    1. I used this tutorial to set up the generate_videos.sh cronjob.
  13. GitHub - Connecting to GitHub with SSH
    1. 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.
  14. AskUbuntu - Install ffmpeg in Ubuntu 12.04 LTS
    1. 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.
    • The solution that worked for me
    • 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

Cloud vs. co-location

Comparison of different cloud providers / VPSes