0. The purpose is to integrate the small and exquisite Nginx and Django through uwsgi
1. Prepare the environment Python 2.7.8 @ ubuntu server 14.04.2 version
2. Install Django (pip is used here, of course easy_install is also available ) sudo pip install django==1.8
3. Install Nginx sudo apt-get install nginx
4. Install uwsgi sudo apt-get install uwsgi
5. Create a Django project +app >>python django-admin.py startproject cloud_shield
>>cd cloud_shield
>>python manage.py startapp cloud_proxy
6. Upload the code and configuration diagram respectively
(Only the configuration diagrams of the main files that need to be modified are given here)
<code>1.首先完善django 的app,即在 cloud_proxy/views.py中写个简单的回复request请求的方法 </code>
<code>settings.py中添加 app和 static_URL </code>
<code> 还有urls.py中添加对用的(r^$ 'cloud_proxy.views.cs_receive_request'),的过滤器 </code>
<code> 其实上面这些对于熟悉Django的同学来说都不用赘述,但是为了让大家不管是否有基础都看清楚细节,还是截图了~ </code>
The above has completed the configuration of django, let’s configure nginx; The configuration file cloud_shield_nginx.conf
in the project root directory must also be placed in the nginx directory as a soft link to let nginx know this configuration file. This soft link must be configured and configured properly. It can also be viewed with vi in sites-enabled; >> sudo ln -s /home/bw/cloud_shield/cloud_shield_nginx.conf /etc/nginx/sites-enabled/
There is also a small For details, there is user www-data in the first line at the beginning of /etc/nginx/nginx.conf; this needs to be changed to user, the current system user; (It would be even better if an account with small permissions is specially customized for the server~)
Finally configure uwsgi
Errors such as 502 may occur during the intermediate configuration process. The solution is as follows:
When system services such as nginx cannot be started: >>tail /var/log/syslog
When there is an internal error in the server: >>tail ~/bw/cloud_shield/uwsgi/uwsgi.log
Want the server to check errors: >>nginx -c some_conf_file
Only nginx’s own files can be checked here
Finally: Below is the tree diagram of the entire project (the folders inside are what they will look like when they are finally completed, and many files are manually created by myself)
Finally, the tree of Nginx is ( Mainly because there is an extra soft link):
With the help of the dns server configured last time, the final result is:
In fact, there are a lot of small details that need to be paid attention to, and I can’t explain them all here. But the general directions and methods to solve the problem are here~
If you have any questions, please feel free to give me some advice~
This article is published simultaneously in the personal forum: http://itpark.sinaapp.com/thread-index-fid-4 -tid-295-typeid1-7-typeid2-0-typeid3-0-typeid4-0.htm
If reproduced, please indicate the source!
The above introduces the Ubuntu Server 14.04.2 LTS configuration Nginx + uwsgi + Django, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.