Windows apache multi-port virtual host configuration method

Source: Internet
Author: User

1. Open httpd. conf, search for Listen: 80, and add Listen: 8080 to the following line;
2. Search for # Include conf/extra/httpd-vhosts.conf and remove the # above this line;
3. Open the httpd-vhosts.conf file under the extra folder under the httpd. conf file directory;
4. Search for NameVirtualHost *: 80 and add NameVirtualHost *: 8080 in the following line;
5. Copy the following code at the bottom of the httpd-vhosts.conf file and paste it below:

Copy codeThe Code is as follows: <VirtualHost *: 80>
ServerAdmin webmaster@dummy-host.abc.com
DocumentRoot "G: \ PHP"
ServerName dummy-host.abc.com
ServerAlias www. dummy-host.abc.ccom
ErrorLog "log/dummy-host.abc.com-error.log"
CustomLog "logs/dummy-host.abc.com-access.log" common
</VirtualHost>

<VirtualHost *: 80>
ServerAdmin webmaster@dummy-host2.abc.com
DocumentRoot "G: \ PHP"
ServerName dummy-host2.abc.com
ErrorLog "log/dummy-host2.abc.com-error.log"
CustomLog "logs/dummy-host2.abc.com-access.log" common
</VirtualHost>

6. Modify the above Code:

Copy codeThe Code is as follows: <VirtualHost *: 8080>
ServerAdmin webmaster@dummy-host.abc.com
DocumentRoot "G: \ PHP \ abc"
ServerName dummy-host.abc.com
ServerAlias www. dummy-host.abc.ccom
ErrorLog "log/dummy-host.abc.com-error.log"
CustomLog "logs/dummy-host.abc.com-access.log" common
</VirtualHost>

<VirtualHost *: 8080>
ServerAdmin webmaster@dummy-host2.abc.com
DocumentRoot "G: \ PHP \ abc"
ServerName dummy-host2.abc.com
ErrorLog "log/dummy-host2.abc.com-error.log"
CustomLog "logs/dummy-host2.abc.com-access.log" common
</VirtualHost>

7. Save and restart apache.

Note:
1. The above code mainly modifies the port and directory. The directory corresponding to port 80 is G: \ PHP, And the directory corresponding to port 8080 is G: \ PHP \ abc;
2. The directory corresponding to the newly added port must be under the Apache directory;
3. Open http: // localhost: 8080 to access the G: \ PHP \ abc directory.

Below are some additional information:

When we want to configure multiple VM hosts and the ports are different, I found a lot on the Internet... this afternoon I summarized the apache configuration of multiple ports./

First, add the Include/etc/httpd/conf/51buyhost. conf statement under http. conf and you will be able to understand it.

Next, let's look...

Copy codeCode: NameVirtualHost *: 8080
#
Listen 8080.
<VirtualHost *: 8080>
DocumentRoot "/var/www/html/goodfoison"
# ServerName jb51.net (commented out for the moment, because only ip addresses are used for access)
ServerName 192.168.0.50
ServerAlias 192.168.0.50
<Directory "/var/www/html/goodfoison">
Allow from all
Options + Indexes
</Directory>
</VirtualHost>

# Szlise.com
Listen 8081.
<VirtualHost *: 8081>
DocumentRoot "/var/www/html/szlise"
# ServerName jb51.net (commented out for the moment, because only ip addresses are used for access)
ServerName 192.168.0.50
ServerAlias 192.168.0.50
<Directory "/var/www/html/szlise">
Allow from all
Options + Indexes
</Directory>
</VirtualHost>

: Wq exit
Study it by yourself ....
Enable the corresponding port in the firewall.

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.