In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Today, the editor will share with you the relevant knowledge points about how to build a high-performance WEB server. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.
I. installation platform
1. Install pcre
The copy code is as follows:
Cd / home
Mkdir-p / home/install/nginx & & cd / home/install/nginx
Wget http://ftp.exim.llorien.org/pcre/pcre-8.00.tar.gz
Tar-zxvf pcre-8.00.tar.gz
Cd pcre-8.00
. / configure
Make & & make install
Cd..
2. Install nginx
The copy code is as follows:
Wget http://nginx.org/download/nginx-0.8.50.tar.gz
Tar-zxvf nginx-0.8.50.tar.gz
Cd nginx-0.8.50/
/ configure-- user=nobody-- group=nobody-- prefix=/usr/local/nginx-- with-http_stub_status_module-- with-cc-opt='-o3'-- with-cpu-opt=opteron
Make & & make install
Cd..
3. Install python&mysql-python
The copy code is as follows:
Wget http://www.python.org/ftp/python/2.5.1/python-2.5.1.tgz
Tar-zxvf python-2.5.1.tgz
Cd python-2.5.1
. / configure & & make & & make install
Echo "export path=\ $path:/usr/local/bin" > > / etc/profile
Source / etc/profile
4. Install mysql-python
The copy code is as follows:
Cd.. /
Wget http://downloads.sourceforge.net/project/mysql-python/mysql-python/1.2.2/mysql-python-1.2.2.tar.gz?r=&ts=1285248455&use_mirror=nchc
Cd mysql-python-1.2.2
Python setup.py install
5. Install django
The copy code is as follows:
Wget http://www.djangoproject.com/download/1.2.3/tarball/
Tar-zxvf django-1.2.3.tar.gz
Cd django-1.2.3
Python setup.py install
Cd..
6. Install uwsgi
The copy code is as follows:
Wget http://projects.unbit.it/downloads/uwsgi-0.9.6.2.tar.gz
Tar-zxvf uwsgi-0.9.6.2.tar.gz
Cd uwsgi-0.9.6.2
Make
Cp uwsgi / usr/bin
II. Platform configuration
1. Platform environment description
1.1.Project location: / opt/www/purgesys
How to create a project:
The copy code is as follows:
Cd / opt/www
Django-admin.py startproject purgesys
1.2. View the project (the following file structure indicates that the project has been created successfully)
# tree purgesys
The copy code is as follows:
Purgesys
| |-_ _ init__.py |
|-- manage.py
|-- settings.py
`--urls.py
2. Nginx related configuration
# cd / usr/local/nginx/conf
# vi django_uwsgi.conf
# django projectserver {listen 80; server_name purgesys.domain.com; location / {uwsgi_pass 127.0.0.1 server_name purgesys.domain.com; location 9000; include uwsgi_params; access_log off;} location ^ ~ / static {root / opt/www/purgesys } location ^ / admin/ {uwsgi_pass 127.0.0.1 uwsgi_pass 9000; include uwsgi_params; access_log off;} location * ^. +\. (mpg | avi | mp3 | swf | zip | tgz | gz | rar | doc | xls | ppt | txt | tar | mid | midi | wav | rtf | mpeg) ${root / opt/www/purgesys/static; access_log off;}}
* uwsgi output header support has been added to nginx-0.8.50 by default
Include uwsgi_params
# vi nginx.conf
Add the sub-profile django_uwsgi.conf
Http {. Include django_uwsgi.conf;}
3. Uwsgi configuration
# mkdir-p / home/uwsgi;cd / home/uwsgi
# mkdir-p / opt/www/logs
# echo "" > / opt/www/logs/django.log
# vi uwsgi.xml
127.0.0.1:9000 200 true / usr/local/nginx/uwsgi.pid 8 / opt/www/purgesys / opt/www/ django_wsgi true true true true 6048 / opt/www/logs/django.log
4. Create an application module
Cd / opt/www/purgesys
Vi django_wsgi.py
Import osos.environ ['django_settings_module'] =' purgesys.settings'import django.core.handlers.wsgiapplication = django.core.handlers.wsgi.wsgihandler ()
5. Start the service
# / usr/bin/uwsgi-x / home/uwsgi/uwsgi.xml
# / usr/local/nginx/sbin/nginx
6. View the process
# [liuts@webserver nginx] # ps-ef | grep uwsgi | grep-v grep
The copy code is as follows:
Root 21652 1 0 17:12? 00:00:00 / usr/bin/uwsgi-x / home/uwsgi/uwsgi.xml
Root 21653 21652 0 17:12? 00:00:00 / usr/bin/uwsgi-x / home/uwsgi/uwsgi.xml
Root 21654 21652 0 17:12? 00:00:00 / usr/bin/uwsgi-x / home/uwsgi/uwsgi.xml
Root 21655 21652 0 17:12? 00:00:00 / usr/bin/uwsgi-x / home/uwsgi/uwsgi.xml
Root 21656 21652 0 17:12? 00:00:00 / usr/bin/uwsgi-x / home/uwsgi/uwsgi.xml
Root 21657 21652 0 17:12? 00:00:00 / usr/bin/uwsgi-x / home/uwsgi/uwsgi.xml
Root 21658 21652 0 17:12? 00:00:00 / usr/bin/uwsgi-x / home/uwsgi/uwsgi.xml
Root 21659 21652 0 17:12? 00:00:00 / usr/bin/uwsgi-x / home/uwsgi/uwsgi.xml
Root 21660 21652 0 17:12? 00:00:00 / usr/bin/uwsgi-x / home/uwsgi/uwsgi.xml
7. Listening port
# [liuts@webserver nginx] # netstat-an | grep 9000
Quote
Tcp 0 127.0.0.1 9000 0.0.0.0 * listen
8. Access testing
Enter http://serverip/
The great task has been completed!
* uwsgi startup script attached
# cd / home/uwsgi
# vi uwsgiserver.sh
#! / bin/bashif [$1 = start]; then psid= `ps aux | grep "uwsgi" | grep-v "grep" | wc-l`if [$psid-gt 2]; then echo "uwsgi is running!" Exit 0 else / usr/bin/uwsgi-x / home/uwsgi/uwsgi.xml fi echo "start uwsgi service [ok]" elif [$1 = stop]; then killall-9 uwsgi echo "stop uwsgi service [ok]" elif [$1 = restart]; then killall-9 uwsgi/ usr/bin/uwsgi-x / home/uwsgi/uwsgi.xml echo "restart uwsgi service [ok]" else echo "usages: sh uwsgiserver.sh [start | stop | restart]" fi
# sh uwsgiserver.sh start
[uwsgi] parsing config file / home/uwsgi/uwsgi.xml
Start uwsgi service [ok]
The following is a supplement:
1. Mysql-python installation error is as follows
From setuptools import setup importerror:
Install first
Python ez_setup.py
In installation
Python setup.py install
Post it for the convenience of other brothers.
2. My nginx+uwsgi+django encounters the request of a big header, and it often appears that 502 header UWSGI reports invalid request header size. Why is my uwsgi configured as [uwsgi] socket =: 8010master = truemodule = 8home = / path/to/virtualenvharakiri = 20daemonize = / path/to/uwsgi.logpidfile = / path/to/uwsgi.pidpythonpath = / path/to/projectpythonpath = / path/to/uwsgibuffer-size = 32768reload-mercy = 8max-requests = 5000socket-timeout = 4
Solution: large header can modify some parameters of nginx http head.
3. Nginx reports 502, but uwsgi starts normally and port 9000 listens normally. It is possible that there is an error in the application.
These are all the contents of the article "how to build a high-performance WEB server". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.