Centos configures the virtual host virtualhost, allowing the server to support multiple websites and multiple domain names

Source: Internet
Author: User
Tags url forwarding
For Apache, you only need to modify the apache configuration file.

For Apache, you only need to modify the apache configuration file/etc/httpd/conf/httpd. conf.

There is an example file in it. you only need to configure it.

#

# ServerAdmin webmaster@dummy-host.example.com

# DocumentRoot/www/docs/dummy-host.example.com

# ServerName dummy-host.example.com

# ErrorLog logs/dummy-host.example.com-error_log

# CustomLog logs/dummy-host.example.com-access_log common

#

You can add at the bottom of httpd. conf by referring to my configuration:

NameVirtualHost *: 80

ServerAdmin admin@example.com

DocumentRoot/var/www/html

ServerName www.phpddt.com

# ErrorLog/var/log/httpd/phpddt/error_log

# Note: Here I set the daily production log

ErrorLog "| rotatelogs/var/log/httpd/phpddt/error_log % Y _ % m _ % d. log 86400 480"

# CustomLog/var/log/httpd/phpddt/access_log common

CustomLog "| rotatelogs/var/log/httpd/phpddt/access_log % Y _ % m _ % d. log 86400 480" common

ServerAdmin admin@example.com

DocumentRoot/var/www/html/blog

ServerName blog.phpddt.com

ErrorLog/var/log/httpd/blog/error_log

CustomLog/var/log/httpd/blog/access_log common


As shown above, I have configured two virtual hosts with the domain names www.phpddt.com blog.phpddt.com respectively.
Note: service httpd restart takes effect only after apache is restarted)

If the reader does not understand anything, I strongly recommend other related articles:

1. you do not need to configure a VM to add a second-level domain name to your website.

2. add a second-level domain name through url Forwarding

3. how does apache generate independent log files every day?

Related Article

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.