In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how to build a high-performance WEB server in Centos". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to build a high-performance WEB server in Centos" can help you solve the problem.
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/
* 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]
If you have any questions or topics of interest, you can communicate with me through weibo: http://t.qq.com/yorkoliu
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.
This is the end of the introduction to "how to build a high-performance WEB server with Centos". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.