Nginx + apache + mysql + php + memcached + squid cluster web environment (16 ). Client | server load balancer | reverse proxy cache | web server | database tutorial server | ------------------------------------------------ nginxsqu client | ==>| server load balancer |==> | reverse proxy/ cache |==>| web server |==>| database tutorial server |
----------------------------------------------------
Nginx squid apache, php mysql tutorial
Preparations for eaccelerator/memcache:
Reference Server: intel (r) xeon (tm) cpu 3.00 ghz x 2, 2 gb mem, scisc hard drive
Operating system: centos4.4, kernel version 2.6.9-22. elsmp, gcc version 3.4.4
Software:
Apache 2.2.3 (mpm mode available)
Php 5.2.0 (this version is used because the engine of 5.2.0 is relatively more efficient)
Eaccelerator 0.9.5 (accelerates the php engine and encrypts the php source program)
Memcache 1.2.0 (used to cache frequently used data)
Libevent 1.2a (required for memcache operating mechanism)
Mysql 5.0.27 (use a binary version to save compilation effort)
Nginx 0.5.4 (used as a server load balancer)
Squid-2.6.stable6 (providing professional caching while doing reverse proxy)
II. compilation and installation
1) install nginx
1) Install
Nginx is pronounced as [engine x] and is a project established by the Russian igor sysoev based on the bsd license. It is said that he was a member of f5, home: http://nginx.net. Some large Russian websites have been using it for more than two years and have been doing well.
The nginx compilation parameters 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, we need to describe the support of the pcre module because I want to use regular expressions in the nginx configuration file. I have installed the rpm Package of pcre and pcre-devel, but ngxin cannot find the. h/. so/. a/. la file correctly, so I changed it a bit:
[Root @ localhost] # mkdir/usr/include/pcre/. libs/
[Root @ localhost] # cp/usr/lib/libpcre. a/usr/include/pcre/. libs/libpcre.
[Root @ localhost] # cp/usr/lib/libpcre. a/usr/include/pcre/. libs/libpcre. la
Then, modify the objs/makefile at the location of approximately 908 rows and comment out the following content:
./Configure -- disable-shared
Next, you can execute make and make install normally.
2) modify the configuration file/usr/local/server/nginx/conf/nginx. conf.
The following is my nginx. conf content for your reference only:
# Running user
User nobody;
# Start a process
Worker_processes 2;
# Global error logs and pid files
Error_log logs/error. log notice;
Pid logs/nginx. pid;
# Working mode and maximum number of connections
Events {
Use epoll;
Worker_connections 1024;
}
# Set the http server and use its reverse proxy function to provide load balancing support
Http {
# Set the mime type
Include conf/mime. types;
Default_type application/octet-stream;
# Set the log format
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 "';
# Set request buffer
Client_header_buffer_size 1 k;
Large_client_header_buffers 4 4 k;
# Enable the gzip module
Gzip on;
Gzip_min_length 1100;
Gzip_buffers 4 8 k;
Gzip_types text/plain;
Output_buffers 1 32 k;
Post pone_output 1460;
# Setting access log
Access_log logs/access. log main;
Client_header_timeout 3 m;
Client_body_timeout 3 m;
Send_timeout 3 m;
Sendfile on;
Tcp_nopush on;
Tcp_nodelay on;
Keepalive_timeout 65;
# Set the server list of server load balancer
Ups tutorial tream mysvr {
# The weigth parameter indicates the weight. a higher weight indicates a higher probability of being assigned.
# Enable port 3128 for squid on the local machine
Server 192.168.8.1: 3128 weight = 5;
Server 192.168.8.2: 80 weight = 1;
Server 192.168.8.3: 80 weight = 6;
} 1 2 3 4 5 6
Listener | = | server load balancer |== | reverse proxy/cache |== | web server |== | database tutorial server | -------- ---------- ------------- ------- ------------ nginx squ...