How to configure multiple sites and domain names in Apache

Source: Internet
Author: User

For example, the Host IP address is 192.168.1.1.

There are three domain names on your host:

Www.a.comPut webpage files in E:/web/www/1

Www. B .comPut webpage files in E:/web/www/2

Www.c.comPut webpage files in E:/web/www/3

Add httpd. conf to Apache

# Set different domain names to different directories

Namevirtualhost 192.168.1.1

<Virtualhost 192.168.1.1>

ServernameWww.a.com

DocumentRoot "E:/web/www/"

</Virtualhost>

<Virtualhost 192.168.1.1>

ServernameWww. B .com

DocumentRoot "E:/web/www/B"

</Virtualhost>

<Virtualhost 192.168.1.1>

ServernameWww.c.com

DocumentRoot "E:/web/www/C"

</Virtualhost>

Restart.

Apache virtualhost example

<Virtualhost *: 80>

Serveradmin linuxpk@msn.com

DocumentRoot/home/linuxpk/web/

Servername linuxpk.com

Serveralias www.linuxpk.com

Directoryindex index.htm index.html index. php

Defaultlanguage ZH-CN

Adddefacharcharset gb2312

Errordocument 404

Http://www.linuxpk.com/error.htmlErrorLog home/linuxpk/log/dummy-linuxpk.com-error_log

Customlog home/linuxpk/log/dummy-linuxpk.com-access_log commom

<Directory "/home/linuxpk/web/">

Options followsymlinks

AllowOverride none

Order allow, deny

Allow from all

</Directory>

<Ifdefine php>

Php_admin_flag engine on

Php_admin_flag safe_mode off

Php_admin_value open_basedir none

Php_admin_value session. save_path "/usr/local/tmp/PHP/session"

Php_admin_value open_basedir "/home/linuxpk/web/;/usr/local/tmp/PHP"

</Ifdefine>

</Virtualhost>

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.