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.