1、先安装PCRE,下载地址
Download pcre-8.35.tar.gz (PCRE)
2、放到/opt目录下,解压压缩包
tar -zxvf pcre-8.35.tar.gz
3、进入安装包目录
cd pcre-8.35
4、编译安装
./configure
make
make install
5、下载nginx路径
6、解压
tar -zxvf nginx-1.24.0.tar.gz
7、安装依赖
yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
8、编译安装
./configure
make
make install
9、进入到cd /usr/local/nginx/conf目录下面(负载设置)
vim nginx.conf
upstream myweb{
server 127.0.0.1:8081 weight=2;
server 127.0.0.1:8082 weight=1;
server 127.0.0.1:8083 weight=1;
}
location / {
root html;
proxy_pass http://myweb;
index index.html index.htm;
}
10、启动,进入安装目录
cd /usr/local/nginx/sbin
./nginx
11、访问
http://虚拟机ip:80