HTTPD virtualhost based on IP, port and domain three ways

Source: Internet
Author: User
Tags mkdir

Native IP eth0:192.168.244.150 eth0:0 192.168.244.158

1, based on the same IP different port virtualhost

Edit httpd.conf New Configuration entry

Vim/etc/httpd/conf/httpd.conf

Listen 8080

Listen 8888

In the following new

<virtualhost 192.168.244.150:8080>

Documentroot/var/www/html/website1

</VirtualHost>

<virtualhost 192.168.244.150:8888>

Documentroot/var/www/html/website2

</VirtualHost>

To create a directory:

Mkdir/var/www/html/website1

Mkdir/var/www/html/website2

echo website1 >/var/www/html/website1

echo Website2 >/var/www/html/website2

Restart Service:/etc/init.d/httpd restart

Browser Browsing Test

Test Normal

2, based on the same port different IP virtualhost

New IP

Ifconfig eth0:0 192.168.244.158

Edit httpd.conf New Configuration entry

Vim/etc/httpd/conf/httpd.conf

<virtualhost 192.168.244.150:8888>

Documentroot/var/www/html/website1

</VirtualHost>

<virtualhost 192.168.244.158:8888>

Documentroot/var/www/html/website2

</VirtualHost>

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.