lnmp之nginx-nanyoujiayu
server3.example.com172.25.85.3server4.example.com172.25.85.4
server5.example.com172.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-developenssl-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
makecert.pem ##生成了cert.pem
cp cert.pem /usr/local/lnmp/nginx/conf/
nginx -t
nginx -s> 在网页中访问:http://server3.example.com 会生成这个key的相关信息
cd/usr/local/lnmp/nginx/conf
vim nginx.conf
usernginx;
worker_processes1;
events {
use epoll;
worker_connections1024;
}
http {
upstream westos{
server 172.25.85.4:80;
server 172.25.85.5:80;
}
include mime.types;
default_typeapplication/octet-stream;
location / {
root html;
indexindex.html index.htm;
}
location /status {
stub_status on;
access_log off;
}
server {
listen 443 ssl;
server_nameserver3.example.com;
ssl_certificate cert.pem;
ssl_certificate_keycert.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout5m;
ssl_ciphersHIGH:!aNULL:!MD5;
ssl_prefer_server_cipherson;
location / {
root html;
indexindex.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> 172.25.85.4server4.example.com
172.25.85.5server5.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.3server3.example.com www.linux.orgwww.unix.org
在网页中打开www.linux.org 不停的刷新,server4.example.com 和 server5.example.com交替出现
页:
[1]