Preface
This note aims to simplify the route to deploy DJANGO2.X<2 on Ubuntu-LTS server. It takes about 4 minutes.
Before you start your Ubuntu server, you ' d better the Change your SSH ports to another one, and never use ' 22 '. Because hackers would try many times to access your server. You can switch your SSH port by following scripts:
cd /etc/init.d/sshlssudo# a configuration file like this# in vim mode, type ‘i‘ to insert# annotate the default port setting as ‘# port 22‘# add a new line after ‘port 22‘ as ‘port 23442‘, just an example.# after you‘ve done above thingssudo /etc/init.d/ssh restart
Install instruction
Debug your Site/app
- Upload your Django files via SFTP, with the same port as ssh
-
Do following jobs:
source ./bin/activatepython3 manage.py makemigrationspython3 manage.py migratepython3 manage.py createsuperuser# set username, pwd, email python3 manage.py runserver 0.0.0.0:8000# then some error might occur< /span>
- Trouble shooting
- Model Fields Error
- Check your field setting
- Check your MySQL charset
- MYSQL Connection Error
- Re-configure your MySQL settings in settings.py
- Checkout your MySQL service status
- Not allowed IP or so
- Add your server public IP address to the settings.py in "Allow" like List
- Makemigrations or migrate do not work well
Configuration
Deploy Django on Ubuntu 16.4 LTS