Configure multiple sites in Apache

Source: Internet
Author: User

APACHE configures a local multi-IP multi-directory VM

Configure the virtual host with the IP address 127.0.1.1 as the yjs.com website folder as E:/yjs.
Step 1:
Open C: \ WINDOWS \ system32 \ drivers \ etc \ hosts
Add

127.0.1.1 yjs.com

Step 2:
Open the conf \ extra \ httpd-vhosts file in the Apache directory
Add

<VirtualHost 127.0.1.1: 80>
DocumentRoot "E:/yjs"
ServerName yjs.com
ErrorLog "E:/yjs/tmp_error_log.txt"
</VirtualHost>

Step 3:

Open the APACHE configuration file httpd. conf.

Remove # Before # Include conf/extra/httpd-vhosts.conf
Add the E:/yjs directory permission at the end of the file.

<Directory "E:/yjs">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow, deny
Allow from all
</Directory>

Step 4:
Restart APACHE

 

**************************************** *******************************

Simple Method of adding multiple directories and ports
Listen 80
Listen 8000.

NameVirtualHost *
# Search for <VirtualHost> definition.
# Set (ADD, originally empty here) the corresponding directory
<VirtualHost localhost: 8000>
ServerName localhost
DocumentRoot "D:/Web/Web8000"
</VirtualHost>

 

**************************************** *******************************
Apache configures multiple sites (non-virtual directories)
For example, you now have a site:
Http: // localhost/
To add a port to run another site:
Http: // localhost: 8080/

Step 1: Create a configuration file
Copy httpd. conf and save it as hooyes. conf (of course, you can get a better name than this one)

Step 2: modify the configuration file
Open the hooyes. conf file
Set the port to Listen: 8080.
Set the website directory:
DocumentRoot "D:/Tweb/hooyes/webroot" (D:/Tweb/hooyes/webroot is the directory of your second site)
<Directory "D:/Tweb/hooyes/webroot"> (this location also needs to be modified)

Step 3: create a service
Httpd.exe-k install-n "service name"-f "X: installation directory \ apache2.2 \ conf \ hooyes. conf"

Additional operations:
# Install Apache as a service:
Httpd-k install
# Specify 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 an Apache service with a specific name:
Httpd-k uninstall-n "service name"
# Generally, the Apache Service Monitor tool is used to start, restart, and shut down the Apache Service. You can also use the following command: net start Apache2 and net stop Apache2 can also be used in 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 # You can use the command line switch to control the Apache service.
# 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
# To restart a running Apache service and force it to re-read the configuration file, you can use:
Httpd-k restart

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.