server2.example.com 172.25.85.2
server4.example.com 172.25.85.4
server5.example.com 172.25.85.5
1.nginx原码编译:
tar zxf nginx-1.9.14.tar.gz
cd /root/nginx-1.9.14/auto/cc
vim gcc
# debug #CFLAGS="$CFLAGS -g"
yum install pcre-devel openssl-devel -y
cd nginx-1.9.14
./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module ##编译成功
make
make install
cd /root
vim .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/nginx/sbin
source .bash_profile
cd /usr/local/lnmp/nginx/sbin/
./nginx -t
./nginx
curl -I localhost
useradd -s /sbin/nologin nginx
usermod -d /usr/local/lnmp/nginx/ nginx
cd /etc/pki/tls/certs
make cert.pem ##生成了cert.pem
cp cert.pem /usr/local/lnmp/nginx/conf/
nginx -t
nginx -s reload
在网页中访问:http://server3.example.com 会生成这个key的相关信息
cd /usr/local/lnmp/nginx/conf
vim nginx.conf
user nginx; worker_processes 1;
events { use epoll; worker_connections 1024; } http { upstream westos{ server 172.25.85.4:80; server 172.25.85.5:80; } include mime.types; default_type application/octet-stream;
location / { root html; index index.html index.htm; } location /status { stub_status on; access_log off; }
server { listen 443 ssl; server_name server3.example.com; ssl_certificate cert.pem; ssl_certificate_key cert.pem; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root html; index index.html index.htm; } }
server { listen 80; server_name www.linux.org; location /{ proxy_pass http://westos; } }
server { listen 80; server_name www.unix.org; location /{ root /web2; index index.html; } }
nginx -t
nginx -s reload
172.25.85.4 server4.example.com
172.25.85.5 server5.example.com
在server4和server5上安装httpd,并打开httpd
echo server4.example.com > /var/www/html/index.html
echo server5.example.com > /var/www/html/index.html
在物理机上作解析:
172.25.85.3 server3.example.com www.linux.org www.unix.org
在网页中打开www.linux.org 不停的刷新,server4.example.com 和 server5.example.com交替出现
原文地址:http://11713145.blog.51cto.com/11703145/1834155