Apache Server sets virtual WEB
Here is an example:
Suppose your PHP is installed in d:/php.
Copy php4apache. dll (php4apache2. dll) to d:/php/
Add the following content to httpd. conf of Aapche:
######################################## ##############
Aapche1 is:
LoadModule php4_module "d:/php/php4apache. dll"
Aapche2 is:
LoadModule php4_module "d:/php/php4apache2. dll"
Add the extension parsed by PHP:
AddType application/x-httpd-php. phtml. pwml. php3. php4. php. php2. inc. izz
######################################## ##############
Now, you only need to restart Apache to support PHP.
# Only Apache1 supports the following line.
LoadModule gzip_module modules/ApacheModuleGzip. dll
ApacheModuleGzip (mod_gzip) is an Apache module provided by Remote Communications for free. It can compress static web pages. It works well. You just need to compile it with apache (or use it as a DSO ).
You can also download it from the site Bingbing:
Http://justdn.com/down/apache/ApacheModuleGzip.dll
More PHP acceleration and buffering suggestions can be obtained in the PHP document of Bingbing.
How does Apache build a virtual host? The following describes a domain name-based VM.
For example, your server address is 61.132.27.69 (this is ice cream). Now we want to build two virtual hosts: www.justdn.org and www.justdn.com.
Add the following code to Apache httpd. conf:
######################################## ##############
NameVirtualHost 61.132.27.69
<VirtualHost 61.132.27.69>
ServerAdmin webmaster@justdn.com
DocumentRoot C:/home/justdn.com/
ServerName www.justdn.com
ServerAlias justdn.com wwww.justdn.com
ErrorLog logs/www.justdn.com-error_log
CustomLog logs/www.justdn.com-access_log common
ErrorDocument 404/404 .html
</VirtualHost>
<VirtualHost 61.132.27.69>
ServerAdmin webmaster@justdn.com
DocumentRoot c:/home/justdn.org/
ServerName www.justdn.org
ServerAlias wwww.justdn.org justdn.org
ErrorLog logs/www.justdn.org-error_log
CustomLog logs/www.justdn.org-access_log common
</VirtualHost>
######################################## ##############
The following explains,
ServerAdmin is the administrator's mailbox.
DocumentRoot is the site document directory of the VM.
ServerName, domain name.
ServerAlias justdn.com wwww.justdn.com indicates that you can access the site either through www.justdn.com or through justdn.com.
ErrorDocument 404/404. html: defines the 404.html file under the site's root directory on the 4th page of the site.
Note:
The settings for using apache server on Unix and NT platforms are the same. The following describes how to configure apache server on the unix platform. In addition, it is worth noting that about 50% of the workload for successful virtual web settings is in domain name registration and resolution. Therefore, you should register the domain name before setting the virtual WEB.
I. IP-type VM
An IP host is the unique IP address of each VM. Multiple IP addresses can be implemented through multiple physical NICs or virtual network interfaces. Both Solaris2.5 and Windows NT support this method.
You can configure multiple VM instances in either of the following ways:
1. Start an httpd process for each VM.
Use this method in the following cases:
1) Security Isolation needs to be considered. For example, two httpd instances run on different users, groups, Listen, and ServerRoot instances. In addition to browsing data through the Web, the two users cannot access other data.
2) provides sufficient memory and file descriptors.
Setting method:
Create an independent httpd installation for each virtual host. In the configuration file httpd. conf of each installation path, use the Listen command to specify the IP address of the process service, for example, Listen 10.68.37.10: 80.
2. Start an httpd process for all virtual hosts.
Use this method in the following cases:
1) allows sharing httpd configurations between virtual hosts.
2) computers serve a large number of requests and run multiple processes to reduce server performance.
Setting method:
In the configuration file httpd. conf, use the VirtualHost command to set ServerAdmin, ServerName, DocumentRoot, ErrorLog, TransferLog, or CustomLog for each virtual host, for example:
<VirtualHost www.smallco.com> # IP address is recommended here
ServerAdmin webmaster@mail.smallco.com
DocumentRoot/usr/local/etc/httpd/htdocs/smallco
ServerName www.smallco.com # we recommend that you use a domain name here
ErrorLog/usr/local/etc/httpd/logs/smallco/error_log
TransferLog/usr/local/etc/httpd/logs/smallco/access_log
</VirtualHost> 〉
<VirtualHost www.baygroup.org> # IP address is recommended here
ServerAdmin webmaster@mail.baygroup.org
DocumentRoot/groups/baygroup/www
ServerName www.baygroup.org # domain names are recommended here
ErrorLog/groups/baygroup/logs/error_log
TransferLog/groups/baygroup/logs/access_log
</VirtualHost> 〉
At the same time, you need to configure the virtual network port or network card, and configure the corresponding settings in DNS.
Ii. Name-based VM (supported by Apache1.3 and later versions)
Although the IP type VM is good, it is not the best solution. It requires each VM to have a dedicated IP address, which is difficult to implement on some machines. A name-based VM has different names, but the IP address is the same. It does not limit the number of virtual hosts. It is easy to configure and use and does not require additional hardware and software. The disadvantage is that the client must support this part of the protocol, which is supported by browsers of recent versions. Some earlier versions of browsers do not. However, Apache provides a solution for this.
Setting method:
In the configuration file httpd. conf, use the NameVirtualHost command to set the virtual host, for example:
NameVirtualHost 111.22.33.44
<VirtualHost 111.22.33.44> # IP address is recommended.
ServerName www. domain. tld # domain name is recommended here
DocumentRoot/web/domain
</VirtualHost> 〉
At the same time, the DNS defines www. domain. tld pointing to 111.22.33.44.
Note: When the IP address is used after the NameVirtualHost command, any URL request using the IP address is for the VM, and the master server will never respond to a URL request using the IP address. In addition, some servers want to be accessed by multiple names. For example, if a server with an IP address wants to be accessed by domain. tld and www2.domain. tld, The ServerAlias command is used in the VirtualHost command. For example, ServerAlias domain. tld *. domain. tld
Additional VM configuration instances are provided.
Appendix: VM instance settings
IP-type VM Configuration
Setup 1: the server has two IP addresses,
111.22.33.44 server. domain. tld
111.22.33.55 www. otherdomain. tld
Www. domain. tld is the alias of server. domain. tld (CNAME), representing the master server.
Server Configuration:
...
Port 80
DocumentRoot/www/domain
ServerName www. domain. tld
<VirtualHost 111.22.33.55> 〉
DocumentRoot/www/otherdomain
ServerName www. otherdomain. tld
...
</VirtualHost> 〉
Setup 2: basically the same as Setup1, but no dedicated master server is set.
Server Configuration:
...
Port 80
ServerName server. domain. tld
<VirtualHost 111.22.33.44> 〉
DocumentRoot/www/domain
ServerName www. domain. tld
...
</VirtualHost> 〉
<VirtualHost 111.22.33.55> 〉
DocumentRoot/www/otherdomain
ServerName www. otherdomain. tld
...
</VirtualHost> 〉
This setting hits the master server only when the URL is http://server.domain.tld
Setup 3: the server has two IP addresses,
111.22.33.44 server. domain. tld
111.22.33.55 www-cache.domain.tld
Www. domain. tld is the alias of server. domain. tld (CNAME), representing the master server.
The www-cache.domain.tld is the proxy-cache, the port is 8080, and the Web server uses the default 80.
Server Configuration:
...
Port 80
Listen 111.22.33.44: 80
Listen 111.22.33.55: 8080
ServerName server. domain. tld
<VirtualHost 111.22.33.44: 80> 〉
DocumentRoot/www/domain
ServerName www. domain. tld
...
</VirtualHost> 〉
<VirtualHost 111.22.33.55: 8080> 〉
ServerName www-cache.domain.tld
...
<Directory proxy:> :〉
Order deny, allow
Deny from all
Allow from 111.22.33
</Directory> 〉
</VirtualHost> 〉
Name-based VM Configuration
Setup 1: the server has an IP address,
111.22.33.44 server. domain. tld.
Www. domain. tld and www. sub. domain. tld are aliases (CNAMEs ).
Server Configuration:
...
Port 80
ServerName server. domain. tld
NameVirtualHost 111.22.33.44
<VirtualHost 111.22.33.44> 〉
DocumentRoot/www/domain
ServerName www. domain. tld
...
</VirtualHost> 〉
<VirtualHost 111.22.33.44> 〉
DocumentRoot/www/subdomain
ServerName www. sub. domain. tld
...
</VirtualHost> 〉
If you use an IP address to access the server, because www. domain. tld has the highest priority, it is considered as the default server or
Server 1.
Setup 2: the server has two IP addresses,
111.22.33.44 server1.domain. tld for master server
111.22.33.55 server2.domain. tld for VM
The alias www. domain. tld is used for the master server,
The alias www. otherdomain. tld is used for a VM,
The alias www. sub. domain. tld, *. sub. domain. tld is used for another VM,
Server Configuration:
...
Port 80
ServerName www. domain. tld
DocumentRoot/www/domain
NameVirtualHost 111.22.33.55
<VirtualHost 111.22.33.55> 〉
DocumentRoot/www/otherdomain
ServerName www. otherdomain. tld
...
</VirtualHost> 〉
<VirtualHost 111.22.33.55> 〉
DocumentRoot/www/subdomain
ServerName www. sub. domain. tld
ServerAlias *. sub. domain. tld
...
</VirtualHost> 〉
Hybrid (IP/Name) VM Configuration
Setup: the server has three IP addresses,
111.22.33.44 server. domain. tld is used for name-Type Virtual Hosts
111.22.33.55 www. otherdomain1.tld for IP-Type Virtual Hosts
111.22.33.66 www. otherdomain2.tld for IP-Type Virtual Hosts
Server Configuration:
...
Port 80
ServerName server. domain. tld
NameVirtualHost 111.22.33.44
<VirtualHost 111.22.33.44> 〉
DocumentRoot/www/domain
ServerName www. domain. tld
...
</VirtualHost> 〉
<VirtualHost 111.22.33.44> 〉
DocumentRoot/www/subdomain1
ServerName www. sub1.domain. tld
...
</VirtualHost> 〉
<VirtualHost 111.22.33.44> 〉
DocumentRoot/www/subdomain2
ServerName www. sub2.domain. tld
...
</VirtualHost> 〉
<VirtualHost 111.22.33.55> 〉
DocumentRoot/www/otherdomain1
ServerName www. otherdomain1.tld
...
</VirtualHost> 〉
<VirtualHost 111.22.33.66> 〉
DocumentRoot/www/otherdomain2
ServerName www. otherdomain2.tld
...
</VirtualHost> 〉
Port-type VM Configuration
Setup: the server has an IP address,
111.22.33.44 www. domain. tld
If you do not need another alias or IP address, you can use a port-type virtual host to set a virtual server with different configurations.
VM instance.
Server Configuration:
...
Listen 80
Listen 8080.
ServerName www. domain. tld
DocumentRoot/www/domain
<VirtualHost 111.22.33.44: 8080> 〉
DocumentRoot/www/domain2
...
</VirtualHost> 〉