程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> nginx+apache+mysql+php+memcached+squid集群web環境 (1/6)

nginx+apache+mysql+php+memcached+squid集群web環境 (1/6)

編輯:關於PHP編程

 客戶端 | ===> |負載均衡器| ===> |反向代理/緩存| ===> |web服務器| ===> |數據庫教程服務器|
-------- ---------- ------------- --------- ------------
nginx squid apache,php mysql教程
eaccelerator/memcache准備工作:
引用服務器: intel(r) xeon(tm) cpu 3.00ghz * 2, 2gb mem, scisc 硬盤
操作系統:centos4.4,內核版本2.6.9-22.elsmp,gcc版本3.4.4
軟件:
apache 2.2.3(能使用mpm模式)
php 5.2.0(選用該版本是因為5.2.0的引擎相對更高效)
eaccelerator 0.9.5(加速php引擎,同時也可以加密php源程序)
memcache 1.2.0(用於高速緩存常用數據)
libevent 1.2a(memcache工作機制所需)
mysql 5.0.27(選用二進制版本,省去編譯工作)
nginx 0.5.4(用做負載均衡器)
squid-2.6.stable6(做反向代理的同時提供專業緩存功能)

二、編譯安裝
一、) 安裝nginx
1.) 安裝
nginx發音為[engine x],是由俄羅斯人igor sysoev建立的項目,基於bsd許可。據說他當初是f5的成員之一,英文主頁:http://nginx.net。俄羅斯的一些大網站已經使用它超過兩年多了,一直表現不凡。
nginx的編譯參數如下:

[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
在這裡,需要說明一下,由於nginx的配置文件中我想用到正則,所以需要 pcre 模塊的支持。我已經安裝了 pcre 及 pcre-devel 的rpm包,但是 ngxin 並不能正確找到 .h/.so/.a/.la 文件,因此我稍微變通了一下:

[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
然後,修改 objs/makefile 大概在908行的位置上,注釋掉以下內容:

./configure --disable-shared
接下來,就可以正常執行 make 及 make install 了。

2.) 修改配置文件 /usr/local/server/nginx/conf/nginx.conf
以下是我的 nginx.conf 內容,僅供參考:

#運行用戶
user nobody nobody;
#啟動進程
worker_processes 2;
#全局錯誤日志及pid文件
error_log logs/error.log notice;
pid logs/nginx.pid;
#工作模式及連接數上限
events {
use epoll;
worker_connections 1024;
}
#設定http服務器,利用它的反向代理功能提供負載均衡支持
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教程tream mysvr {
#weigth參數表示權值,權值越高被分配到的幾率越大
#本機上的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;
} 1 2 3 4 5 6

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved