普通的nginx配置
egrep -v "#|^$" /usr/local/nginx/conf/nginx.conf.default
更改nginx的配置文件-->注意空格和封号
cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
vim /usr/local/nginx/conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.baobaotao.com;
location / {
root html/baobaotao;
index index.html index.htm;
}
}
server {
listen 80;
server_name www.etiantian.com;
location / {
root html/bbs;
index index.html index.htm;
}
}
server {
listen 88;
server_name www.blog.com;
location / {
root html/blog;
index index.html index.htm;
}
}
}
创建虚拟站点目录
mkdir -p /usr/local/nginx/html/baobaotao
mkdir -p /usr/local/nginx/html/etiantian
mkdir -p /usr/local/nginx/html/blog
echo "www.baobaotao.com" > /usr/local/nginx/html/baobaotao/inhtml
echo "www.etiantian.com" > /usr/local/nginx/html/etiantian/index.html
echo "www.blog.com" > /usr/local/nginx/html/blog/index.html
检查配置,重启服务
cd /usr/local/nginx/sbin
./nginx -t 【测试ok后重启服务,-t 表示测试】
./nginx -s reload 【测试ok,重启服务】
配置hosts
echo "192.168.25.144 www.baobaotao.com" >> /etc/hosts
echo "192.168.25.144 www.etiantian.com" >> /etc/hosts
echo "192.168.25.144 www.blog.com" >> /etc/hosts
tail /etc/hosts
说明:blog设置的是88端口