windows apache multi port virtual host configuration method
- 2020-05-09 19:38:52
- OfStack
1. Open httpd.conf, find Listen:80, and add Listen:8080 in the following line.
2. Look for #Include conf/extra/ httpd-vhosts. conf, remove the # before this line;
3. Open the httpd-vhosts.conf file under the extra folder under the httpd.conf file directory;
4. Find NameVirtualHost *:80, and add NameVirtualHost *:8080 to the next line.
5. Copy the following code at the bottom of the httpd-vhosts. conf file and paste one copy below:
<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. Modify the above code 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 "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.
Remark:
1. The above code is mainly used 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 supplementary 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 concluded that I had finally configured apache for multiple ports by 1 afternoon
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 ofstack.com ( 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 ofstack.com ( 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>
: wq exit
Study on your own...
Then open the corresponding port inside the firewall