We are setting the default encoding to UTF-8, which Django expects. We are also setting the default transaction isolation scheme to “read committed”, which blocks reads from uncommitted transactions. Lastly, we are setting the timezone. By default, our Django projects will be set to use UTC. These are all recommendations from the Django project itself:
1 2 3 4 5
CREATEUSER myprojectuser WITH PASSWORD 'password'; ALTER ROLE myprojectuser SET client_encoding TO'utf8'; ALTER ROLE myprojectuser SET default_transaction_isolation TO'read committed'; ALTER ROLE myprojectuser SET timezone TO'UTC'; GRANTALL PRIVILEGES ON DATABASE myproject TO myprojectuser;
Create a Python 3 Virtual Environment for your Project
Next, check for the existence of the myproject.sock file within your project directory:
1 2
ls /home/sammy/myproject manage.py myproject myprojectenv myproject.sock static
View gunicorn logs
1
sudo journalctl -u gunicorn
If you make changes to the /etc/systemd/system/gunicorn.service file, reload the daemon to reread the service definition and restart the Gunicorn process by typing:
Finally, we need to open up our firewall to normal traffic on port 80. Since we no longer need access to the development server, we can remove the rule to open port 8000 as well: