Nginx Virtual Host alias configuration

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.