Centos 6.6 configure vhost in the LAMP environment Apache

Source: Internet
Author: User

Centos 6.6 configure vhost in the LAMP environment Apache

1. Open the apache configuration file (httpd. conf), usually in/etc/httpd/conf/httpd. conf

A) Enable LoadModule vhost_alias_module modules/mod_vhost_alias.so (enable the method to delete the '#' before the sentence)

B) In Include conf. d /*. conf write Include conf/extra/httpd-vhosts.conf (this sentence is added to the conf extra folder under the httpd-vhosts.conf file, so this path can be placed in other directories, such as conf. d directory)

C) Set NameVirtualHost *: 80

All the above words can be added with '/' in command mode in vi, such as/vhost. Note that the words are case sensitive.

2. Create an extra directory under the conf directory (use the mkdir extra command to create extra, which is the path used in the above configuration path)

A) create a httpd-vhosts.conf in the extra directory (you can create it using the vi httpd-vhosts.conf)

B) enter the following code:

① UseWww.xx1.comMake the first domain name

<VirtualHost *: 80>

ServerNameWww.xx1.comThe domain name of xx1 is used as an instance.

DocumentRoot "/var/www/html/xx1" here is the folder referred to by the Domain Name

<Directory "/var/www/html/xx1"> the folder specified by the Domain Name

Options Indexes FollowSymLinks ExecCGI Includes

AllowOverride All

Order allow, deny

Allow from all

</Directory>

</VirtualHost>

② UseWww.xx2.comMake the first domain name

<VirtualHost *: 80>

ServerNameWww.xx2.comThe xx2 domain name is used as an instance.

DocumentRoot "/var/www/html/xx2" the folder specified by the Domain Name

<Directory "/var/www/html/xx2"> the folder specified by the Domain Name

Options Indexes FollowSymLinks ExecCGI Includes

AllowOverride All

Order allow, deny

Allow from all

</Directory>

</VirtualHost>

More ......

3. restart the server: (common method: service httpd restart or/etc/init. d/httpd 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.