Django&MySQL environment deployment under Ubuntu 14.04

Python environment setup##

Operating system Ubuntu14.04, comes with Python2.7.6

im@58user:/$ python
Python 2.7.6(default, Oct 262016,20:30:19)[GCC 4.8.4] on linux2
Type "help","copyright","credits" or "license"for more information.>>>

Django environment setup ##

The current version of Django has reached 1.11. Go to the official website to download the file corresponding to Linux, then unzip & install. (Official website download address)

tar xzvf Django-1.11.x.tar.gz
cd Django-1.11.x
sudo python setup.py install

At this time, it may prompt ImportError: No module named setuptools

Execute sudo https://bootstrap.pypa.io/ez_setup.py -O-| sudo python

Then execute sudo python setyp.py install

So far, Django is installed successfully~!

MysqlInstall##

Execute the following command, you may need to enter the root password and confirm it during operation.

sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysqld-dev

Then link MySQL and Python

sudo apt-get install python-dev
sudo wget https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.5.zip
unzip MySQL-python-1.2.5.zip
cd MySQL-python-1.2.5/
sudo python setup.py install

The way to enter the mysql database:

Set the root password for mysql: ####

First enter mysql in the first way

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A

Database changed
mysql> update user set Password =PASSWORD('root') where User ='root';
Query OK,3 rows affected(0.00 sec)
Rows matched:3  Changed:3  Warnings:0
mysql> exit
In brackets'root'Is the new password

New Project##

Time to verify the results
Switch the current directory to Python's Worspace, and enter the new project name:

im@58user:~/PythonProjects$django-admin.py startproject Hello
im@58user:~/PythonProjects$ cd Hello/
im@58user:~/PythonProjects/Hello$ tree
├── Hello
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── manage.py

Next we write a HelloWorld page.
Create a views.py file in the first level directory under the Hello file

im@58user:~/PythonProjects/Hello$ touch views.py
im@58user:~/PythonProjects/Hello$ ls
Hello  manage.py  views.py
im@58user:~/PythonProjects/Hello$ tree
.
├── Hello
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── manage.py
└── views.py

1 directory,6 files

Write the following code in the views.py file

from django.http import HttpResponse

def hello(request):returnHttpResponse("Hello World~!~!")

Then add the path to the urls.py file

from django.conf.urls import url
from django.contrib import admin
from views import hello

urlpatterns =[url(r'^admin/', admin.site.urls),url(r'^hello/', hello),]

Then execute in the Hello directory```python manage.py runserver 0.0.0.0:8080

Open the browser and visit http://127.0.0.1:8000/hello/ to see the display results.

![ Hello world](http://upload-images.jianshu.io/upload_images/1319879-a19f1df512b51616.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

To read more articles of the author, you can check my [personal blog](http://dandanlove.com/) and public account:
![ Revitalization Book City](http://upload-images.jianshu.io/upload_images/1319879-612c4c66d40ce855.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

Recommended Posts

Django&MySQL environment deployment under Ubuntu 14.04
ubuntu environment deployment project
[CentOS environment deployment] Java7/Java8 deployment under CentOS
FFmpeg environment deployment record under centos7
PPTP environment deployment record under Centos
JDK environment variable configuration method under ubuntu
Build the C++ compilation environment under ubuntu
GPU programming (1): CUDA8.0 environment construction under Ubuntu
Build a python development environment under Ubuntu
Configure Nginx + PHP 7.0 + MySQL environment under Ubuntu 16.04
Production environment deployment of ubuntu Django + Uwsgi + Nginx
Install apache+PHP under Ubuntu
Install node.js under Ubuntu
ubuntu16.04 deploy GPU environment
Install python3.6 under Ubuntu 16.04
Install mysql under Ubuntu 16.04
Install Thrift under ubuntu 14.10
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
Python MySQLd under Ubuntu
Ubuntu configuration development environment
Start working under ubuntu
[python] python2 and python3 under ubuntu
Use iptables under ubuntu
Ubuntu development environment configuration
2018-09-11 Install arduino under Ubuntu
LNMP installation under Ubuntu
Network configuration under Ubuntu
Python virtual environment: Ubuntu16.04
Ubuntu Touch environment setup
Ubuntu18.10 configure Java environment
Install ROS under ROS Ubuntu 18.04[2]
Install MySQL under Ubuntu
Install Yarm-PM2 under Ubuntu
SFTP dual-machine high availability environment deployment record under Centos
Resolve the problems encountered in the linux environment under ubuntu
Deploy FTP server under ubuntu
Build docker environment under Centos6.5
Install python environment under Linux
ubuntu sets python2.5 environment variables
Solve Unment dependencies under ubuntu
ubuntu14.0464 Ros environment install halcon13.01
Open SSH service under Ubuntu
Use sublime tex under ubuntu
Modify shortcut keys under Ubuntu 18.04
Ubuntu deployment and experience Nexus3
Use of mediawiki under ubuntu
Install server-side Shadowsocks under Ubuntu 16.04
Open SSH service under Ubuntu
Detailed steps for installing Django under Python 3.6 in Ubuntu 16.04 environment
DNS service construction under Ubuntu
Method of setting up PHP operating environment under Ubuntu server
ubuntu build python development environment
ubuntu builds common development environment
ubuntu offline installation python environment
Install rgl package under Ubuntu
Ubuntu 18.04.1 build Java environment and HelloWorld
Deploy JobConverter + Ibreoffice environment on Ubuntu
Ubuntu environment variables and ADB configuration
Use QQ under Ubuntu 13.10, suitable for 14.10
RabbitMQ cluster deployment record under Centos6.9