Do not place the VM on a common port; otherwise, the VM directory is entered by default. ServerRoot & quot;/var/lib/apache2.2 & quot; DocumentRoot & quot;/var/lib/apache2.2/htdocs & quot; ErrorLog & quot; logs/error_log & quot ;#
Do not place the VM on a common port; otherwise, the VM directory is entered by default.
ServerRoot "/var/lib/apache2.2"
DocumentRoot "/var/lib/apache2.2/htdocs"
ErrorLog "logs/error_log"
# Apache parsing. php files
SetHandler application/x-httpd-php
# Myproject.com
Listen 192.168.55.9: 80
DocumentRoot/var/lib/apache2.2/htdocs/myproject
ServerName myproject.com
# ScriptAlias/cgi-bin/"/var/lib/apache2.2/htdocs/myproject/cgi-bin /"
# Myproject1.com
Listen 192.168.55.9: 81
DocumentRoot/var/lib/apache2.2/htdocs/myproject1
ServerName myproject1.com
# ScriptAlias/cgi-bin/"/var/lib/apache2.2/htdocs/myproject1/cgi-bin /"
We also need to perform IP ing in the hosts file of the client, that is:
192.168.55.9 myproject.com
192.168.55.9 myproject1.com
However, we do not need to map IP addresses in the hosts on the server.
In fact, we still use port 80 to respond to the request.
After testing, the above method has a problem: even if it is accessed through myproject1.com, it still enters myproject.com.
Change to the following:
ServerRoot "/var/lib/apache2.2"
DocumentRoot "/var/lib/apache2.2/htdocs"
ErrorLog "logs/error_log"
SetHandler application/x-httpd-php
NameVirtualHost *: 80
Listen 192.168.55.9: 80
# Myproject.com
DocumentRoot/var/lib/apache2.2/htdocs/myproject
ServerName myproject.com
# ScriptAlias/cgi-bin/"/var/lib/apache2.2/htdocs/myproject/cgi-bin /"
# Myproject1.com
DocumentRoot/var/lib/apache2.2/htdocs/myproject1
ServerName myproject1.com
# ScriptAlias/cgi-bin/"/var/lib/apache2.2/htdocs/myproject1/cgi-bin /"