yum -y install gcc gcc-c++ autoconf automake zib zib-devel openssl openssl-devel pcre pcre-devel
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0/
./configure --prefix=/usr/local/nginx-1.8.0 --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module
make -j 4 && make install
useradd -u 8000 -s /sbin/nologin nginx
/usr/local/nginx-1.8.0/sbin/nginx
echo "/usr/local/nginx-1.8.0/sbin/nginx &" >> /etc/rc.local
nginx的操作
cd /usr/local/nginx-1.8.0/sbin/
./nginx -t
./nginx -s reload|stop
cd /usr/local/nginx-1.8.0/conf/
cp nginx.conf nginx.conf.back
vim nginx.conf
user nginx nginx;
// 在 location {...}内添加以下内容
if ($request_uri ~* \.html$){
proxy_pass http://htmlservers;
}
if ($request_uri ~* \.php$){
proxy_pass http://phpservers;
}
proxy_pass http://picservers;
upstream htmlservers {
server 192.168.221.20:80;
server 192.168.221.30:80;
}
upstream phpservers {
server 192.168.221.20:80;
server 192.168.221.30:80;
}
upstream picservers {
server 192.168.221.20:80;
server 192.168.221.30:80;
}
检测语法,重新加载nginx.conf
../sbin/nginx -t
../sbin/nginx -s reload
yum install httpd php -y
在网站根目录下创建以下文件
启动 httpd
service httpd start
安装httpd php,在网站根目录下创建 index.html,test.php,1.png,启动httpd服务
停止 192.168.221.20机器上的httpd服务,再次访问
这样就会一直访问到192.168.221.30上的站点
原文地址:http://blog.51cto.com/13480443/2105404