Ngnix+uwsgi+django+python+mysql Environment Deployment

Source: Internet
Author: User
Tags mkdir parent directory install django pip install django virtual environment

Django
A Python web framework
Flask and Django

Uwsgi
A Python container

Nginx
A Web server can be the front end of a web container

Client--->nginx--->uwsgi (beginning port)--->web page

Virtualenv virtualenvwrapper Python Development Virtual Environment installation Python3: Download python3.6 to download #xz-D compression package. XZ Prep Environment: #yum Install zlib* openssl* readline* sqlite*-y install Python3 # cd Python-3.6.4 #./configure--prefix =/usr/local/python3.6 && make && make install # Rm-rf/usr/bin/python # ln-s/usr/local        /python3.6/bin/python3/usr/bin/python processing yum (after Python upgrade, Yum is not available, he uses the default 2.7) # Vim/usr/bin/yum to change the interpreter to 2.7         #!/usr/bin/python2.7 A soft connection to pip: # ln-s/usr/local/python3.6/bin/pip3/usr/bin/pip # vim ~/.bash_profile Path= $PATH: $HOME/bin:/usr/local/python3.6/bin/#source ~/.bash_profile Installing Django # pip Install Django ==1.10 Create a Django project: Firstsite #cd ~ #django-admin.py startproject firstsite #cd ~/firstsite Sync database: #./manage.py mi Grate #./manage.py Createsuperuser Set static file directory: # VIM firstsite/settings.py//Find the Static keyword first, append the following line static_root = O S.path.join (Base_dir, "static/") #./manage.py collectstatic test Django is available: #./manage.py runserver 0.0.0.0:443 Browser access: Http://xian gmu.buy360.xyz:443 Browser access: Http://xiangmu.buy360.xyz:443/admin installation Uwsgi: #pip install UWSGI Test UWSGI: # UWS GI--http:443--chdir/root/firstsite-w firstsite.wsgi--http: Port--chdri project Directory-W WSGI module Create UWSGI profile: #mkd Ir-p/etc/uwsgi/sites# Vim/etc/uwsgi/sites/firstsite.ini [uwsgi]project = firstsite//project name username = root//Run     User base =/% (username)/////project directory parent Directory chdir =% (base)/% (Project)//item Directory module =% (Project). wsgi:application master = trueprocesses = 5uid =% (username) socket =/run/uwsgi/% (project). Sockchown-socket =% (username): Nginxchmod-sock ET = 660vacuum = true Create Uwsgi boot profile: # Vim/etc/systemd/system/uwsgi.service[unit]description=uwsgi Emperor service[ Service]execstartpre=/usr/bin/bash-c ' Mkdir-p/run/uwsgi; Chown Root:nginx/run/uwsgi ' Execstart=/usr/local/python3.6/bin/uwsgi--emperor/etc/uwsgi/siteSrestart=alwayskillsignal=sigquittype=notifynotifyaccess=all[install]wantedby=multi-user.target The following two steps do not start the service is unsuccessful: #mkdir/root/uwsgi#ln-s/usr/local/python3.6/bin/uwsgi/root/uwsgi/uwsgi Installation nginx: #yum install nginx configuration nginx:# vim/etc/    nginx/nginx.conf Add the following virtual host Configuration server {Listen 80;    server_name firstsite.com www.youngfit.cn;    Location = favicon.ico {access_log off; log_not_found off;}    location/static/{root/root/firstsite;        } location/{include uwsgi_params;    Uwsgi_pass Unix:/run/uwsgi/firstsite.sock; }} Test nginx config file Syntax correctness: # nginx-t Set permissions: # USERMOD-A-G root nginx# chmod 710/root start Nginx and Uwsgi services: #systemctl start Ngin X #systemctl start Uwsgi test: Browser address bar: http://xiangmu.buy360.xyz

Ngnix+uwsgi+django+python+mysql Environment Deployment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.