Original
Method One: Multiple Apache services
Change the root directory of the first site:
Look for the DocumentRoot attribute in file apache2.2/conf/httpd.conf, and change the following path to the path of your primary site.
such as: D:/www/web1
To create a configuration file for the second Apache service:
Copy and rename httpd.conf to web2.conf (for example, it can be called my.conf, etc.),
Modify the web2.conf in the
Listen 8080 (formerly 80)
ServerName localhost:8080 (formerly 80)
DocumentRoot "D:/www/web2″ (formerly Web1)
Add a second Apache service:
In the Apache installation directory, under the bin subdirectory, install Apache as a Windows NT service using the following command:
Httpd.exe-k install-n "service name"-F "d:/apache2.2/conf/web2.conf"
Other commands:
To install Apache as a Windows NT service:
Httpd-k Install
Specify the name of the service, and when you install multiple Apache services on the same machine, you must specify a different name for them.
Httpd-k install-n "Service Name"
To use different profiles for services of different names, you need to specify the configuration file when you install:
Httpd-k install-n "service name"-F "c:/files/my.conf"
If you are using the first command, that is, there are no other command-line arguments except the-K install, the installed service name will be: Apache2, and the configuration file will use conf/httpd.conf.
Removing an Apache service:
Httpd-k Uninstall
Use the command below to remove the Apache service with a specific name:
Httpd-k uninstall-n "Service Name"
In general, the Apache Service Monitor tool is used to start, restart, and shut down services, and you can also use the console command: net start Apache2 and net STOP Apache2 or through the Windows Services Control Panel. Before starting the Apache service, you should use the following command to check the correctness of the configuration file:
Httpd-n "service Name"-T
You can control the Apache service via command-line switches. To start an Apache service that is already installed, you can use:
Httpd-k start
To stop an already installed Apache service, you can use:
Httpd-k stop
Or
Httpd-k shutdown
To restart a running Apache service and force it to reread the configuration file, you can use:
Httpd-k restart
Method Two: Configure the virtual host
Single-IP single-port multi-site
Modify Httpd.conf
--------------------------------------------------------------------------------------------------------------- --------------------
Listen 80
Namevirtualhost 192.168.1.15 #接收请求的IP地址
<virtualhost 192.168.1.15> #绑定的ip
ServerAdmin test@test. com #管理员邮箱
DocumentRoot "d:/inetpub/www/maidou/" #网站目录
ServerName www.test.com #主机名 (domain name)
DirectoryIndex index.php #主目录默认页
Serveralias test.other.com admin.other.com #做出响应的域名
Errorlog Logs/error_log.log #错误日志
Customlog Logs/custom.log Common #用户日志
<directory "d:/inetpub/www/maidou/" >
Options Indexes FollowSymLinks
AllowOverride all #AllowOverride指明Apache服务器是否加载. htacess
Order Allow,deny
Allow from all
</Directory>
</VirtualHost>
# Multiple units can be added again
<virtualhost 192.168.1.15>
DocumentRoot "d:/inetpub/www/other/"
ServerName www.other.com
<directory "d:/inetpub/www/other/" >
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,deny
Allow from all
</Directory>
</VirtualHost>
**************************************************------------------------------------------------------------- ---------------------
The above settings of the listening port is 80, to ensure that the domain name is different.
If you have multiple virtual hosts at the same time and are constantly changing, you can add a sentence at the end of the httpd.conf file
--------------------------------------------------------------------------------------------------------------- ------
Include dir/*.conf #DIR为你虚拟主机配置文件的目录
--------------------------------------------------------------------------------------------------------------- ------
Then, the configuration of each virtual host to make a separate. conf file, placed in the Dir directory, then just add delete files can be
multi-IP single-port multi-site
Modify Httpd.conf
--------------------------------------------------------------------------------------------------------------- --------------------
<virtualhost 192.168.1.1:80>
DocumentRoot "/usr/local/apache/a"
ServerName www.a.com
Serveralias a.com
DirectoryIndex index.html index.php
</VirtualHost>
Namevirtualhost 192.168.1.2:80
<virtualhost 192.168.1.2:80>
DocumentRoot "/usr/local/apache/b"
ServerName www.b.com
Serveralias B.Com
DirectoryIndex index.php
</VirtualHost>
<virtualhost 192.168.1.2:80>
DocumentRoot "/USR/LOCAL/APACHE/C"
ServerName www.c.com
Serveralias c.com
DirectoryIndex index.php
</VirtualHost>
--------------------------------------------------------------------------------------------------------------- ----------------------
Multi-IP multiport multi-site
Modify Httpd.conf
--------------------------------------------------------------------------------------------------------------- ----------------------
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080
<virtualhost 172.20.30.40:80>
Documentroot/www/example1-80
ServerName www.example1.com
</VirtualHost>
<virtualhost 172.20.30.40:8080>
documentroot/www/example1-8080
ServerName www.example1.com
</VirtualHost>
<virtualhost 172.20.30.50:80>
Documentroot/www/example2-80
ServerName www.example1.org
</VirtualHost>
<virtualhost 172.20.30.50:8080>
documentroot/www/example2-8080
ServerName www.example2.org
</VirtualHost>
***********************************************---------------------------------------------------------------- ------
Settings for virtual directories
--------------------------------------------------------------------------------------------------------------- -------
Alias/phpmyadmin "E:/www"
<directory "E:/www" >
AllowOverride None
Options Indexes FollowSymLinks includes
Order Allow,deny
Allow from all
</Directory>
*******************************-------------------------------------------------------------------------------- ---------
Add a virtual directory named Test and point to the E:/www directory
Windows Apache configures multiple service sites