noahdasilva.com is a blog/portfolio Django-based website for Noah Da Silva.
To deploy this project, SSH into the machine running the website's services (Nginx server, Postgres database, and python virtual environment).
ssh -p 22 user@ip_adress
Next, navigate to the project directory
cd /projectdir
We will need to pull the latest version of the project's repository.
git pull
NOTE: If there are local overwrite issues, you can reset the branch. This will erase anything tracked by Git and will not touch untracked local files.
git fetch --all
git reset --hard origin/master
When making changes to the project's models, you may need to make apply the migrations.
source django-venv/bin/activate
python manage.py makemigrations
python manage.py migrate
deactivate
Finally, we can restart the server.
If you update your Django application, you can restart the Gunicorn process to pick up the changes. The gunicorn socket might also need to be restarted.
sudo systemctl restart gunicorn
If you change the Nginx server block configuration, test the configuration and then restart the Nginx process.
sudo nginx -t && sudo systemctl restart nginx
If you change Gunicorn socket or service files, reload the daemon and restart the process.
sudo systemctl daemon-reload
sudo systemctl restart gunicorn.socket gunicorn.service
To write code on a blog post, you will need to select 'Source' under the content editor and add the following code:
<pre><code>code goes here</code></pre>