Nginx+apache+mysql+php+memcached+squid Cluster Web Environment (1/6)

Source: Internet
Author: User
Tags memcached mysql tutorial php mysql php mysql tutorial

Client| ===> | Load Balancer | ===> | Reverse proxy/Caching| ===> |web Server | ===> |Database TutorialsServer |
-------- ---------- ------------- --------- ------------
Nginx squid apache,php mysql Tutorial
Eaccelerator/memcache Preparatory work:
Referral server: Intel (R) Xeon (tm) CPU 3.00ghz * 2, 2GB mem, Scisc hard Drive
Operationsystem: centos4.4, kernel version 2.6.9-22.ELSMP,GCC version 3.4.4
Software:
Apache 2.2.3 (can use MPM mode)
PHP 5.2.0 (This version is chosen because of the 5.2.0enginerelatively more efficient)
Eaccelerator 0.9.5 (accelerated PHP engine, but also can encrypt PHP sourceprogram)
Memcache 1.2.0 (Used for cachingData)
Libevent 1.2a (required by memcache working mechanism)
MySQL 5.0.27 (choose binary version, save compile work)
Nginx 0.5.4 (used as a load balancer)
Squid-2.6.stable6 (provides professional caching while doing a reverse proxy)function)

Ii. Compiling and installing
One,) installation Nginx
1.) Installation
Nginx is pronounced [engine x], established by the Russian Igor Sysoev.Project, based on BSD license. It is said that he was originally a member of the F5, English homepage:http://nginx. NET。 Some of Russia's big websites have been using it for more than two years, and have been performing extraordinary things.
The compilation parameters for Nginx are as follows:

[Root@localhost]#./configure--prefix=/usr/local/server/nginx--with-openssl=/usr/include
--with-pcre=/usr/include/pcre/--with-http_stub_status_module--without-http_memcached_module
--without-http_fastcgi_module--without-http_rewrite_module--without-http_map_module
--without-http_geo_module--without-http_autoindex_module
Here, it needs to be explained that because of the nginx configurationfileI want to use the regular, so I need pcre.Module's support. I have installed the RPM package for Pcre and Pcre-devel, but Ngxin is not able to find the. h/.so/.a/.la file correctly, so I'm a little bit flexible:

[Root@localhost] #mkdir/usr/include/pcre/.libs/
[Root@localhost] #cp/usr/lib/libpcre.a/usr/include/pcre/.libs/libpcre.a
[Root@localhost] #cp/usr/lib/libpcre.a/usr/include/pcre/.libs/libpcre.la
Then, modify the Objs/makefile about 908 lines, commenting out the following:

./configure--disable-shared
Next, you will be able to perform the made and make install normally.

2.) Modify the configuration file/usr/local/server/nginx/conf/nginx.conf
The following is my nginx.conf content, for reference only:

#运行用户
User nobody nobody;
#启动进程
Worker_processes 2;
#全局错误Logand PID files
Error_log Logs/error.log Notice;
PID Logs/nginx.pid;
#工作模式及连接数上限
Events {
Use Epoll;
Worker_connections 1024;
}
#设定http服务器, using its reverse proxy function to provide load balancing support
HTTP {
#设定mime类型
Include Conf/mime.types;
Default_type Application/octet-stream;
#设定日志格式
Log_format Main ' $remote _addr-$remote _user [$time _local] '
' $request ' $status $bytes _sent '
"$http _referer" "$http _user_agent"
' $gzip _ratio ';
Log_format Download ' $remote _addr-$remote _user [$time _local] '
' $request ' $status $bytes _sent '
"$http _referer" "$http _user_agent"
' $http _range ', ' $sent _http_content_range ';
#设定请求缓冲
Client_header_buffer_size 1k;
Large_client_header_buffers 4 4k;
#开启gzip模块
gzip on;
Gzip_min_length 1100;
Gzip_buffers 4 8k;
Gzip_types Text/plain;
Output_buffers 1 32k;
Postpone_output 1460;
#设定access Log
Access_log Logs/access.log Main;
Client_header_timeout 3m;
Client_body_timeout 3m;
Send_timeout 3m;
Sendfile on;
Tcp_nopush on;
Tcp_nodelay on;
Keepalive_timeout 65;
#设定负载均衡的服务器列表
UPS Tutorials Tream Mysvr {
#weigth参数表示权值, the higher the weight, the greater the chance of being assigned.
#本机上的squid开启3128端口
Server 192.168.8.1:3128 weight=5;
Server 192.168.8.2:80 weight=1;
Server 192.168.8.3:80 weight=6;
}

home 1 2 3 4 5 6 last
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.