Wu Yuxiong - natural born Django framework Development Notes: Django Nginx + uwsgi installation configuration

The Nginx + django to uwsgi installation configuration 
to run the server using python manage.py runserver. This applies only to the use of the test environment. 
The official release of the service, need a stable and consistent server, such as apache, Nginx, lighttpd, etc.
Mounting base development kit 
Installation Steps Centos follows: 
yum groupinstall " Development Tools " 
yum the install zlib -devel bzip2-devel-devel PCRE OpenSSL-devel the ncurses-devel SQLite the readline-devel devel-TK-devel
CentOS comes with Python 2.4.3, but you can install Python2.7.5 : 
cd ~ 
wget HTTP: //python.org/ftp/python/2.7.5/Python-2.7.5 .tar.bz2 
tar xvf Python -2.7. . 5 .tar.bz2 
CD the Python -2.7.5 
. / Configure --prefix = / usr / local 
the make && the make altinstall
Installation package management Python 
easy_install pack HTTPS: //pypi.python.org/pypi/ the distribute 
installation steps: 
CD ~ 
wget HTTPS: //pypi.python.org/packages/source/d/distribute/distribute-0.6.49 .tar .gz 
tar XF the distribute -0.6.49 .tar.gz 
cd the distribute -0.6.49 
python2. 7 setup.py install 
easy_install - Version 

pip package:: HTTPS //pypi.python.org/pypi/ pip 
benefits of installing pip is a pip list, pip uninstall Python package management, easy_install does not have this feature, only uninstall.
Installation uwsgi 
uwsgi: HTTPS: //pypi.python.org/pypi/ uWSGI 

uwsgi Detailed parameters: HTTP: //uwsgi-docs.readthedocs.org/en/latest/ options.html 
PIP install uwsgi 
uwsgi --version     # View uwsgi version of the 
test is normal uwsgi: 
New test.py file, as follows: 
DEF the Application (env, start_response): 
    start_response ( ' 200 the OK ' , [( ' content-Type ' , ' text / HTML ' )])
     return  " the Hello World " 
then in a terminal run: 
uwsgi --http: 8001 --wsgi- File test.py 
in the browser enter: http://127.0.0.1:8001 to see if " the Hello World " output, if there is no output, check the installation process.
Install Django 
PIP install django 
test django is normal, run: 
django - admin.py startproject demosite 
cd demosite 
. Python2 7 manage.py the runserver 0.0.0.0:8002 
in the browser enter: HTTP: //127.0.0.1:8002, check whether django operating normally.
Mounting the Nginx 
CD ~ 
wget HTTP: //nginx.org/download/nginx-1.5.6 .tar.gz 
the tar XF Nginx -1.5.6 .tar.gz 
CD Nginx -1.5.6 
. / Configure --prefix = / usr /local/nginx-1.5.6 \
 --with- http_stub_status_module \
 --with- http_gzip_static_module 
the make && the make install 
can install Nginx configuration read to learn more: HTTPS: //www.runoob.com/linux/nginx-install- setup.html
uwsgi configuration 
uwsgi support ini, XML, and other configurations to ini example, in the / etc / New uwsgi9090.ini directory, add the following configuration: 
[uwsgi] 
Socket = 127.0.0.1:9090 
Master = to true // host process 
Vhost = to true // multidrop mode 
nO -site = to true // not set the inlet modules and files multidrop mode 
Workers = 2 // child process number 
reload -mercy = 10      
Vacuum = to true // exit clean restart file 
max 1000 = -REQUESTS    
limit -as = 512 
Buffer -size = 30000 
the PidFile = /var/run/uwsgi9090.pid // pid file for the following script to start and stop the process 
daemonize= /website/uwsgi9090.log
Nginx configuration 
found nginx is installed (eg: / usr / local / nginx /), open the conf / nginx.conf document, modify the configuration server: 
server { 
        the listen        80 ; 
        server_name localhost; 
        
        LOCATION / {             
            the include uwsgi_params; 
            uwsgi_pass   127.0.0.1: 9090; // must be set in the same uwsgi 
            uwsgi_param UWSGI_SCRIPT demosite.wsgi;   // file entry, i.e., relative to the project root wsgi.py position, corresponding to a directory "." 
            uwsgi_param UWSGI_CHDIR / demosite; // item root 
            index index.html index.htm; 
            client_max_body_size 35m;  
        }
    }
After setup, running in a terminal: 

uwsgi --ini /etc/uwsgi9090.ini & 
/ usr / local / nginx / sbin / nginx 
in the browser input: HTTP: //127.0.0.1, you can see the django " It Work " a.

 

Guess you like

Origin www.cnblogs.com/tszr/p/12127978.html