使用nginx来负载均衡 本文在window与linux下配置nginx实现负载

2019-10-15 20:14:12刘景俊

 cd /usr/src/pcre-7.8;
 ./configure --prefix=/usr/local/pcre --enable-utf8 --enable-unicode-properties 

 

       下面编译安装nginx     

 

     开始配置要编译的参数(注:内容较长,容易输错。具体参数设置参见http://wiki.codemongers.com/NginxChsInstall)

    ./configure --prefix=/usr/local/nginx  --sbin-path=/usr/local/nginx/sbin/nginx  --conf-path=/usr/local/nginx/conf/nginx.conf
--error-log-path=/usr/local/nginx/logs/error.log --http-log-path=/usr/local/nginx/logs/access.log
--pid-path=/usr/local/nginx/var/nginx.pid --lock-path=/usr/local/nginx/var/nginx.lock
--http-client-body-temp-path=/dev/shm/nginx_temp/client_body --http-proxy-temp-path=/dev/shm/nginx_temp/proxy
--http-fastcgi-temp-path=/dev/shm/nginx_temp/fastcgi
--user=www --group=www --with-cpu-opt=pentium4 --without-select_module --without-poll_module
--with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module
--without-http_ssi_module --without-http_userid_module --without-http_geo_module --without-http_memcached_module
--without-http_map_module" #如要取消ssl可去掉该项
--without-mail_pop3_module --without-mail_imap_modul --without-mail_smtp_module --with-pcre=/usr/local/pcre/lib

 

     接下来就开始编译生成相应的文件了:

   make
   make install 

 

     然后/dev/shm 也就是内存中,建立一个nginx_temp文件夹

 

   接着创建www用户和组,以及其使用的目录:    

   /usr/sbin/groupadd www -g 48 
   /usr/sbin/useradd -u 48 -g www www 
   mkdir -p /data0/vshare/htdocs 
   chmod +w /data0/vshare/htdocs 
   chown -R www:www /data0/vshare/htdocs 

 

   这时可以扩充一下文件句柄数(windows下就没这么容易扩展了,哎)   

  

   到这里,我们就可以使用linux下的vi编辑器编辑一下:

   cd /usr/src/nginx-0.7.62/conf/