From 7c565afbe3020e66e0a5a865fdf40c0c5bae9a91 Mon Sep 17 00:00:00 2001 From: PLUJA <64632615+pluja@users.noreply.github.com> Date: Fri, 4 Sep 2020 23:07:30 +0200 Subject: [PATCH 1/2] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8406aec..8e3fd70 100644 --- a/README.md +++ b/README.md @@ -95,10 +95,10 @@ You can test this new version. > Now you are inside of the virtual environment for python. All instructions wiht [env] indicate that must be done inside the env if you decided to create one. From now on, you will always need to start the application from within the virtual env. 5. [env] Update pip - - `python3 pip install --upgrade pip` + - `pip install --upgrade pip` 6. [env] Install the required libraries: - - `python3 pip install -r requirements.txt` + - `pip install -r requirements.txt` > If you get errors, try running `source venv/bin/activate` again of use `--user` option. 7. [env] Initialize and prepare the database. From 7f9458df3f069a18d73b9a3809108893caf03f14 Mon Sep 17 00:00:00 2001 From: PLUJA <64632615+pluja@users.noreply.github.com> Date: Fri, 4 Sep 2020 23:09:52 +0200 Subject: [PATCH 2/2] Update SELF-HOSTING.md --- SELF-HOSTING.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/SELF-HOSTING.md b/SELF-HOSTING.md index d38f5b2..ac01ff0 100644 --- a/SELF-HOSTING.md +++ b/SELF-HOSTING.md @@ -14,7 +14,7 @@ * `sudo apt-get -y install python3 python3-venv python3-dev` -* `sudo apt-get -y install mysql-server supervisor nginx git make` +* `sudo apt-get -y install mysql-server supervisor nginx git` > When installing MySQL-server it will prompt for a root password. Set up a password of your like, this will be the MySQL databases master password and will be required later, so don't forget it! @@ -38,7 +38,12 @@ 5. Install gunicorn (production web server for Python apps) and pymysql: `pip install gunicorn pymysql` -6. Set up `.env` +6. Set up the database tables: +* `flask db init` +* `flask db migrate` +* `flask db upgrade` + +7. Set up `.env` 1. (PRE) Generate a random string and copy it to clipboard: `python3 -c "import uuid; print(uuid.uuid4().hex)"` @@ -70,9 +75,7 @@ mysql> quit; If your set up was correct, you should now be able to run: -`flask db init` - -`flask db upgrade` +* `flask db upgrade` #### Step 3: Setting up Gunicorn and Supervisor When you run the server with flask run, you are using a web server that comes with Flask. This server is very useful during development, but it isn't a good choice to use for a production server because it wasn't built with performance and robustness in mind. Instead of the Flask development server, for this deployment I decided to use gunicorn, which is also a pure Python web server, but unlike Flask's, it is a robust production server that is used by a lot of people, while at the same time it is very easy to use. [ref](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvii-deployment-on-linux)