——Python should be installed by default in ubuntu
Install the official release version: Download the installation package in http://www.djangoproject.com/download/, unzip it and install it:
sudopythonsetup.pyinstall
Check if Django is installed: Type in the python shell:
>>> import django
>>> django.VERSION
If it has been successfully installed, you should be able to see the version number in the style of (1, 5, 1,'final', 0)
Type directly in the shell
sudo apt-get install mysql-server
You can install MySQL
You will be prompted to enter a password in the middle, you can enter it or leave it alone
Check whether MySQL is installed:
netstat -tap|grep mysql
If the installation is successful, you should be able to see information like tcp 0 0 localhost:mysql : LISTEN
Then you can enter in the shell
mysql -u root -p
Enter the MySQL shell (if you set a password during installation, you need to enter the password), and perform various database operations
sudo apt-get install python-mysqldb
1 ) Open settings.py and find this paragraph:
DATABASES ={'default':{'ENGINE':'django.db.backends.', # Add 'postgresql_psycopg2','mysql','sqlite3' or 'oracle'.'NAME':'', # Or path to database file if using sqlite3.'USER':'', # Not used with sqlite3.'PASSWORD':'', # Not used with sqlite3.'HOST':'', # Set to empty string for localhost. Not used with sqlite3.'PORT':'', # Set to empty string fordefault. Not used with sqlite3.}}
2 ) Configure'ENGINE' as django.db.backends.mysql
3 )'NAME' is configured as the DB name to be selected, such as mydb
4 )'USER''PASSWORD' input the corresponding user name and password
5 ) The configuration of'HOST' is in doubt, I just leave it empty as if it works.
6 ) Test configuration:
Run python shell in the ``mysite'' project directory
python manage.py shell
Enter these commands to test your database configuration:
>>> from django.db import connection
>>> cursor = connection.cursor()
If no error message is displayed, then your database configuration is correct. Otherwise, you have to view the error message to correct the error.
Reference: http://www.djangobook.com/en/2.0/chapter05.html
The environment configuration is almost like this, write here first, and then change it if you have any problems
Recommended Posts