nginx
安装nginx
--解压nginx压缩包
tar -zxvf nginx-1.12.1.tar.gz
--安装所需要的依赖
yum install openssl openssl--devel
yum install zlib zlib-devel
yum install pcre pcre-devel
yum install gcc-c++
cd nginx-1.12.1
./configure
make && make install
--检查是否成功
find -name nginx
负载均衡的实例
修改/usr/local/nginx/conf/nginx.conf文件
--添加
upstream xyc{
server 192.168.241.128:8080;
server 192.168.241.128:8081;
}
--在server中添加
location / {
#root html;
#index index.html index.htm;
proxy_pass http://xyc;
}
判断配置文件是否正确
cd /usr/local/nginx/sbin
./nginx -t
启动或重启nginx
--启动
cd usr/local/nginx/sbin
./nginx
--重启
cd /usr/local/nginx/sbin
./nginx -s reload
用作静态资源服务器
把静态资源放入到/usr/local/nginx目录下
修改/usr/local/nginx/conf/nginx.conf文件
--在server中添加
location /text {
root /usr/local/nginx;
index login.html;
}