三:Nginx的一些基础应用
【基于ip地址的虚拟主机】(vim /etc/nginx/nginx.conf)
添加两块网卡:eth0 192.168.145.100
eth0:0 192.168.145.101
server {
listen 192.168.145.100:80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 192.168.145.101:80;
server_name localhost;
location / {
root /tec;
index index.html index.htm;
}
error_log /var/log/nginx/tec_error.log;
access_log /var/log/nginx/tec_access.log;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
【基于主机头的虚拟主机】(vim /etc/nginx/nginx.conf)
server {
listen 192.168.145.100:80;
server_name www.wpp.com;
location / {
root html;
index index.html index.htm;
}
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 192.168.145.100:80;
server_name tec.wpp.com;
location / {
root /tec;(这个目录要自己建立,目录下放置主页html文件)
index index.html index.htm;
}
error_log /var/log/nginx/tec_error.log;
access_log /var/log/nginx/tec_access.log;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
【加密访问】
Step1:建立证书颁发机构CA
①vim /etc/pki/tls/openssl.cnf