windows apache multiport virtual host configuration method
- 2020-05-06 12:08:55
- OfStack
1. Open httpd.conf, find Listen:80, add Listen:8080 in the following line;
2. Look for #Include conf/extra/ httpd-vhosts.conf, and remove the # before the line;
3. Open the httpd-vhosts.conf file under the extra folder under the httpd.conf file directory;
4. Find NameVirtualHost *:80, add NameVirtualHost *:8080 in the following line;
5. Copy the following code at the bottom of the httpd-vhosts.conf file and paste
at the bottom
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.abc.com
DocumentRoot "G:\PHP"
ServerName dummy-host.abc.com
ServerAlias www.dummy-host.abc.ccom
ErrorLog "logs/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 "logs/dummy-host2.abc.com-error.log"
CustomLog "logs/dummy-host2.abc.com-access.log" common
</VirtualHost>
6. Change the above code to
<VirtualHost *:8080>
ServerAdmin webmaster@dummy-host.abc.com
DocumentRoot "G:\PHP\abc"
ServerName dummy-host.abc.com
ServerAlias www.dummy-host.abc.ccom
ErrorLog "logs/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 "logs/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 is mainly to modify 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.
here is some additional information:
I found a lot of bullshit on the Internet when we were trying to configure multiple virtual machines with different ports... This afternoon, I summarized an afternoon to finally get the apache configuration for multiple ports fixed./
First in http. conf below add a Include/etc/httpd/conf / 51 buyhost conf later knew this sentence.. Ha ha
Let's move on...
NameVirtualHost *:8080
#
Listen 8080
<VirtualHost *:8080>
DocumentRoot "/var/www/html/goodfoison"
#ServerName jb51.net ( I'm not going to use the notes for now , Because only ip To visit the )
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 ( I'm not going to use the notes for now , Because only ip To visit the )
ServerName 192.168.0.50
ServerAlias 192.168.0.50
<Directory "/var/www/html/szlise">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
: exit
wq Take your time...
Then open the corresponding port in the firewall