标签:lin deb jobs nec pip3 pre ftp another SQ
This note aims to simplify the route to deploy Django2.X<2 on Ubuntu 16 LTS server. It takes about 4 minutes.
Before you start your Ubuntu server, you‘d better change your ssh port to another one, never use ‘22‘. Because hackers will try many times to access your server. You can switch your ssh port by following scripts:
cd /etc/init.d/ssh
ls
sudo vim sshd_config # 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 things
sudo /etc/init.d/ssh restartInstall
sudo apt update
sudo apt-get install mysql-server mysql-clientConfigure
service mysql status
service mysql start #restart/stopInitialize Databases
mysql -u root -p
mysql: create database Django_Database_Name default charset utf8 collate utf8_general_ci; # Set default charset as UTF-8 to prevent error in futureInstall Dependencies: VirtualEnv(Optional)
# install virtualenv
sudo apt install virtualenv
virtualenv Your_Django_App_Root_Name # e.g. Fucker
cd Fucker
source ./bin/activate # activate virtual-environmentDeactivate virtual-environment
# in virtual-environment root dir
deactivateInstall Dependencies: Python3 + pip3
sudo apt-get install python3
sudo apt-get install python3-pipInstall Dependencies: uWSGI + Django
pip3 install django uwsgi pillow --user # --user option to prevent Permission Denied Error in futureInstall Dependency: Nginx
sudo apt-get install nginx
systemctl nginx status # check nginx status
sudo apt install curl # test nginx
curl 127.0.0.1do following jobs:
source ./bin/activate
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py createsuperuser
# set username, pwd, email
python3 manage.py runserver 0.0.0.0:8000
# then some error might occuruse following scripts to clear your specific app‘s migrations cache
python3 manage.py makemigrations --empty YOUR-APP-NAME
python3 manage.py makemigrations
python3 manage.py migrate Django Daemon service configuration
Serve Static files if DEBUG‘s been set False
Nginx Configuration
Deploy Django on Ubuntu 16.4 LTS
标签:lin deb jobs nec pip3 pre ftp another SQ
原文地址:https://www.cnblogs.com/cmsax/p/9010667.html