四.安装配置SVR1
1. 安装基本开发库,以及依赖的软件包
- #yum groupinstall "Development Libraries" "Development Tools"
- #yum -y install pcre-devel
2.安装配置nginx
- useradd -s /sbin/nologin nginx
- #cd /usr/src
- #tar xzvf nginx-1.2.2.tar.gz
- #cd nginx-1.2.2
- #./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx/nginx.pid \
- --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module \
- --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module \
- --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy \
- --http-fastcgi-temp-path=/var/tmp/nginx/fcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
- --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre
- #make && make install
3.为nginx提供服务启动脚本
- 见 二.2.2 的配置内容
4.编辑nginx主配置文件,配置负载均衡
- #vim /usr/local/nginx/conf/nginx.conf
- user nginx;
- worker_processes 10;
- error_log logs/error.log crit;
- pid logs/nginx.pid;
- events
- {
- use epoll;
- worker_connections 51000;
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- keepalive_timeout 60;
- tcp_nodelay on;
- #指定负载均衡的方式
- upstream bbs.andy.com {
- server 172.16.0.2:80;
- server 172.16.0.3:80;
- ip_hash;
- }
- server {
- listen 80;
- server_name bbs.andy.com;
- index index.html index.htm index.php;
- location / {
- proxy_pass http://bbs.andy.com;
- proxy_next_upstream http_502 http_504 error timeout invalid_header;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_connect_timeout 600;
- proxy_read_timeout 600;
- proxy_send_timeout 600;
- proxy_buffer_size 8k;
- proxy_temp_file_write_size 64k;
- }
- access_log logs/bbs.log;
- }
- }
3.重启nginx服务
- #service nginx restart
五,收尾配置,
1,需要在每台服务器上执行以下命令
- #chkconfig iptables off
- #service iptables stop
- #setenforce 0
- #echo "setenforce 0" >> /etc/rc.local
2.需要在SVR4上挂载nfs共享
- #mkdir /web
- #mount -t nfs 172.16.0.3:/web /web
- #echo "mount -t nfs 172.16.0.3:/web /web" >> /etc/rc.local
OK.到这里配置就结束了。
