Nginx 负载均衡配置实例详解

一、 windows下安装以及配置nginx

二、 Linux下安装配置Nginx
一、安装Nginx
1、上传nginx-1.6.2.tar.gz至/usr/local

2、执行如下命令解压nginx:

1.#cd /usr/local
2.#tar zxvf nginx-1.6.2.tar.gz
3、编译安装nginx

1.#cd nginx-1.6.2
2.#./configure --with-http_stub_status_module --with-http_ssl_module #启动server状态页和https模块
执行完后会提示一个错误,说缺少PCRE library 这个是HTTP Rewrite 模块,也即是url静态化的包
可上传pcre-7.9.tar.gz,输入如下命令安装:

1.#tar zxvf pcre-7.9.tar.gz
2.#cd pcre-7.9
3.#./configure
4.#make
5.#make install
安装pcre成功后,继续安装nginx

1.#cd nginx-1.6.2
2.#./configure
3.#make
4.#make install
4、nginx安装成功后的安装目录为/usr/local/nginx

安装完成后执行以下操作验证安装是否成功:
1.cd  /usr/local/nginx/sbin  
2../nginx -t 

结果显示:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
至此,nginx的安装已成功完成。

启动nginx 
1.cd /usr/local/nginx/sbin
2../nginx //启动nginx
在浏览器中输入:http://localhost验证nginx是否成功启动

停止nginx
1.pkill -9 nginx


三、 附录
1、Nginx官网下载地址:
   http://nginx.org/en/download.html
2、Nginx负载均衡配置实例详解
   http://www.php100.com/html/program/nginx/2013/0905/5525.html

猜你喜欢

转载自huangliangbao.iteye.com/blog/2218282