Home >Database >Mysql Tutorial >The whole process of environment deployment of MySQL and Django under Ubuntu14.04
This article mainly introduces Django and MySQL# under Ubuntu 14.04 ##The whole process of environment deployment is introduced in detail through the step-by-step Installation steps. I believe it has certain reference value for everyone. Friends in need can take a look below.
Brief steps. (Ubuntu14.04)
1. Python environment setup
Operating system Ubuntu14.04, comes with Python2.7.6
im@58user:/$ python Python 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
2. Django environment Build
##The current version of Django has reached 1.11. First go to the official website to download the Linux corresponding file, then unzip & install it (official website download address)
tar xzvf Django-1.11.x.tar.gz cd Django-1.11.x sudo python setup.py install
module
named setuptools<a href="http://www.php.cn/code/8212.html" target="_blank">Execute </a><pre class="brush:bash;">sudo https://bootstrap.pypa.io/ez_setup.py -O - | sudo python</pre>
and then execute
python setyp.py install"
The Django installation is successful~ !
3. Mysql installationExecute the command, you may need to enter the root password and confirm during operation sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysqld-dev
Then connect to MySQL. 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
How to enter
mysql database:
> * sudo mysql * mysql -u root -p 然后输入密码
4. Set the root password for mysql
##First Enter mysql in the first waymysql> 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
The 'root' in the brackets is the new password
5. Create a new project
Arrived It’s 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
Configuration file
, this article mainly modifies database information and templates. Information about directories and loaded modules.* url.py: URL configuration file, specifying the mapping relationship between functions
and URLs.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): return HttpResponse(“Hello World~!~!”)Then add the path Add it 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 it in the Hello directory
python manage.py runserver 0.0.0.0:8080
Start the server
Open the browser and visit
You can see the display results.
The above is the detailed content of The whole process of environment deployment of MySQL and Django under Ubuntu14.04. For more information, please follow other related articles on the PHP Chinese website!