Today we want to introduce the use of APT source direct apt-getinstall installation configuration we need environment, first install MySQL and Nginx according to the Convention first: linuxidc@www.linuxidc.com :~ $ Sudosu-root@www.linuxidc.com :~ $ Apt-getinstallmysql-serverroot@www.linuxidc.com :~ $
Today, we will introduce how to directly install and configure the environment we need using APT source apt-get install. First, install MySQL and Nginx as usual:
- Linuxidc @ www.linuxidc.com:~$Sudo su-
- Root @ www.linuxidc.com:~$Apt-Get install mysql-Server
- Root @ www.linuxidc.com:~$Apt-Get install nginx
Then we can find the required uWSGI in sid through the Debian Packages website. To use the software package in sid, we also need to modify our/etc/apt/sources. list source, add the deb http://ftp.tw.debian.org/debian sid main non-free contrib line, or directly enter the command:
- Root @ www.linuxidc.com:~$Echo "deb http://ftp.tw.debian.org/debian sid main non-free contrib">/etc/apt/sources. list
After configuring the source list, we can install it using the following command:
- Root @ www.linuxidc.com:~$Apt-Get update
- Root @ www.linuxidc.com:~$Apt-Get install uwsgi-Core uwsgi-Plugin-Python
After the installation is complete, the configuration file is put in the/etc/uwsgi by convention, service control can be achieved through the invoke-rc.d uwsgi followed by command parameters, but here there is an episode I have to mention, the following error may be reported during installation:
The following packages have unmet dependencies:
Libc6-dev: Breaks: gcc-4.4 (<4.4.6-4) but 4.4.5-8 is to be installed.
E: Broken packages
It seems that the gcc version of the dependent package does not match. I solved it in the following way:
- Root @ www.linuxidc.com:~$Apt-Get update
- Root @ www.linuxidc.com:~$Apt-Get upgrade # first try to upgrade the system software package
- Root @ www.linuxidc.com:~$Apt-Get install libc6-Dev
Next, install MySQL support for django and Python and continue the APT command:
- Root@ Notebook:~$Apt-Get install python-Django python-Mysqldb
View the python version of the application.
- Root@ Notebook:/Usr/Lib $ python--Version
As you know, django is installed under site-packages in the python directory, but none of these python directories have the site-packages folder, in fact, we can use the following command to locate the problem:
- Root@ Notebook:/Usr/Lib $ python-C"From distutils. sysconfig import get_python_lib; print get_python_lib ()"
The above command prints the Python package path on the console. For example, here we may obtain the dist-packages directory. Switch to this directory and you will find django there. Add permissions to the django-admin.py, and then make a symbolic connection so that we can operate later (I am here Django under Python2.7 ):
- Root@ Notebook:/Usr/Lib $ chmod 777/Usr/Lib/Python2.7/Dist-Packages/Django/Bin/Django-Admin.Py
Now, the installation section is basically complete. The configuration section is explained below. First, create a folder for our project, for example, put it under/opt/www, run the following command to create a Django project named mysite:
- Root@ Notebook:~$Cd/Opt/Www
- Root@ Notebook:/Opt/Www $ django-Admin.Py startproject mysite
Now, the/opt/www directory should have a sub-folder named mysite. We need to drop a wsgi configuration file to/opt/www/mysite, the configuration file is named wsgi. py, the content is as follows:
- # Wsgi.Py
- #/Opt/Www/Mysite/Wsgi.Py
- ImportSys
- ImportOS
-
- Sys.Path.Append(OS.Path.Abspath(OS.Path.Dirname(_ File __)))
- # The following line shows the parent directory of mysite.
- Sys.Path.Append('/Opt/www')
- # Change the values in the following line to the corresponding project name..Settings
- # Here Is mysite.Settings
- OS.Environ['Django _ SETTINGS_MODULE'] = 'Mysite. settings'
-
- ImportDjango.Core.Handlers.Wsgi
-
- Application=Django.Core.Handlers.Wsgi.WSGIHandler()