Deploy multiple projects in Apache

Source: Internet
Author: User

The following two methods are implemented by Google by configuring multiple IP addresses and multiple ports. It is not possible to publish multiple projects with a single IP address. If you have any method, please leave a message and learn.

1. Configure multiple IP addresses

Simply put, open httpd. conf and add the following content at the end:

<VirtualHost 127.0.0.2:80>   DocumentRoot d:/AppServ/www2   ServerName 127.0.0.2:80< irtualHost><Directory "d:/AppServ/www2">   Options Indexes FollowSymLinks Multiviews   AllowOverride All   Order Allow,Deny   Allow from all</Directory>

"D:/appserv/www2" stores your site directory: After you restart apache2, your VM is configured. Then, you can access different sites through 127.0.0.2 and 127.0.0.3.

The detailed analysis is as follows:

When we install Apache, the default Apache configuration usually has only one website, which is inconvenient to switch. In fact, this problem is well solved by configuring Apache on the local machine as a virtual server. However, most tutorials on the Internet teach you how to configure a domain name-based virtual host using Apache. When debugging a website on the local machine, it is generally accessed directly using a local IP address (127.0.0.1 or localhost, no domain name is used. Therefore, you must configure Apache as an IP address-based virtual host.

First, we all know that all IP addresses starting with 127 should point to the local machine, not only 127.0.0.1. You can try this.
In this way, the host has enough IP addresses for you to open a VM.

To put it bluntly, go to the official configuration work. The configuration section in httpd. conf of Apache is as follows (httpd. conf is in apache2.2 \ conf ):
1. In the listen section, the port must be specified directly without an IP address. The configuration should be written as follows:
Listen 80
2. You do not need to write "namevirtualhost" like a domain name-based virtual host ".

3. VM configuration section: add

<VirtualHost 127.0.0.2:80>   DocumentRoot d:/AppServ/www2   ServerName 127.0.0.2:80< irtualHost><VirtualHost 127.0.0.3:80>   DocumentRoot d:/AppServ/www3   ServerName 127.0.0.3:80< irtualHost>...

4. Configure the directory attributes accordingly. The following is a typical configuration of the Directory attributes:

<Directory "d:/AppServ/www2">   Options Indexes FollowSymLinks Multiviews   AllowOverride All   Order Allow,Deny   Allow from all</Directory><Directory"d:/AppServ/www3">   Options Indexes FollowSymLinks Multiviews   AllowOverride All   Order Allow,Deny   Allow from all</Directory>

After you restart apache2, your VM is configured. Then, you can access different sites through 127.0.0.1, 127.0.0.2, and 127.0.0.3.

2. Configure multiple ports

Configure Apache and implement multiple sites

After installing Apache, you can enter http: // localhost in the browser to test. If the configuration is normal, it's working will be displayed. Change the root directory of the first site:Find the DocumentRoot attribute in the file apache2.2 \ conf \ httpd. conf, and change the following path to the path of your main site, for example, D: \ www \ web1. Create a configuration file for the second apache service:Copy and rename httpd. conf is web2.conf (for example, it can also be called my. conf), modify listen8080 (originally 80), servername localhost: 8080 (originally 80), and DocumentRoot "D:/www/web2" in web2.conf"
(Originally web1) Add the second apache service:Apache installation directory binRun the following command to install Apache as the WindowsNT service: httpd.exe-K install-n "service name"-F "D: \ apache2.2 \ conf \ web2.conf" Other commands:Install Apache as a Windows NT Service: httpd-K install specifies the service name. When You Install Multiple Apache services on the same machine, you must specify different names for them. When httpd-K install-n "service name" uses different configuration files for services with different names, you must specify the configuration file during installation: 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 parameters except-K install, the installed Service name will be: apache2, the configuration file will use conf \ httpd. conf. Remove an apache service: httpd-K uninstall use the following command to remove the apache service with a specific name: httpd-K uninstall-n "service name" generally, you can use the Apache servicemonitor tool to start, restart, and shut down the apache service. You can also use the Console Commands: Net start apache2 and net stop apache2, or use the Windows Service 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 through the command line switch. To start an installed apache service, you can use: httpd-K start to stop an installed apache service. You can use: httpd-K stop or httpd-K shutdown must restart a running Apache service and force it to re-read the configuration file. You can use:

Httpd-K restar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.