1. Modify the Hosts file
[Root@slave html]# vi/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.203 www.wolf.com bbs.wolf.com blog.wolf.com wolf.com
2. Modify the configuration file
[Root@slave nginx]# VI 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.wolf.com wolf.com;
Location/{
Root html/www;
Index index.html index.htm;
}
}
server {
Listen 80;
server_name bbs.wolf.com;
Location/{
Root Html/bbs;
Index index.html index.htm;
}
}
server {
Listen 80;
server_name blog.wolf.com;
Location/{
Root Html/blog;
Index index.html index.htm;
}
}
"Nginx.conf" 38L, 751C written
3. Grammar check
[Root@slave nginx]#/usr/sbin/nginx-t
Nginx:the configuration file/etc/nginx/nginx.conf syntax is OK
Nginx:configuration file/etc/nginx/nginx.conf Test is successful
4. Restart Service
[Root@slave nginx]#/usr/sbin/nginx-s Reload
5. Testing
[Root@slave nginx]# Ping wolf.com
PING www.wolf.com (192.168.0.203) bytes of data.
Bytes from www.wolf.com (192.168.0.203): icmp_seq=1 ttl=64 time=0.097 ms
Bytes from www.wolf.com (192.168.0.203): icmp_seq=2 ttl=64 time=0.039 ms
[Root@slave nginx]# Curl wolf.com
Http://www.wolf.com
[Root@slave nginx]# Curl www.wolf.com
Http://www.wolf.com
The above describes the Nginx virtual host alias configuration, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.