Django Enviroment in Tencent Cloud Ubuntu

Django Enviroment in Tencent Cloud Ubuntu

Exchange blogroll: http://laker.me/blog
Github:https://github.com/younglaker

Enviroment:

  • MacOS
  • Tencent Cloud Ubuntu 18.04
  • Python 3.6
  • Django 2.0

Connect to server

Connect via SSH

In MacOs, it’s very easy to connect to the server. In terminal :

1
ssh -q -l ubuntu -p [port] [ip]

Like ssh -q -l ubuntu -p 20 188.131.***.***.

Login with password.

Python

In Ubuntu18.04, there are two versions of Pyhton: 2.7 and 3.6. The default version is 2.7, If you don’t want to change, then skip following steps.

Alter to python3.6:

1
2
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150

Check whether it successes:

1
2
$ python --version
Python 3.6.7

Django

Install pip:

1
$ sudo apt install python3-pip

Check whether it successes:

1
2
$ pip --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

Install specific Django version :

1
$ sudo pip install Django==2.1.2

Create a project

1
2
cd /data
sudo django-admin startproject helloworld

Modify the write permission for everyone :

1
sudo chmod 666 /data/helloworld/helloworld/settings.py

Edit the settings:

1
2
$ cd helloworld/helloworld/
$ vim settings.py

Add your IP in ALLOWED_HOSTS = [] to ALLOWED_HOSTS = ["188.131.***.***"]

Save and quit vim:

1
:wq

Open port 8080 in Baota Panel:

Open port 808

Or set in Tencent Cloud:

Open port 808

Run the project :

1
2
$ cd ../
$ sudo python manage.py runserver 0.0.0.0:8080

Visit the website:

website

Reference:
ubuntu + nginx + uwsgi + django(python3)
python3+Django


Django Enviroment in Tencent Cloud Ubuntu

本文原创自http://laker.me/blog,转载请注明出处,欢迎交换友链

如果本文对您有帮助,微信扫一扫,请我吃个鸡腿吧

评论组件不稳定,有事请联系V信 lakerHQ (请备注来自博客)