Apache Server Advanced Setup Guide (ii)

Source: Internet
Author: User
Tags mail modify domain domain name
Apache| Server | Advanced III, Virtual Host (VM) settings

As a system administrator, if you have only one IP address, but there are several domain names, but also require access to each domain name to see different content, then how to do? There is no one server for each domain. This will take the virtual host technology, and fortunately Apache supports this functionality. There are two ways to have a virtual host: ip-based (ip-based), name-based (based on domain name). Ip-based refers to a domain name corresponding to an IP address, and name-based refers to multiple domain names corresponding to an IP address.

The setup of the virtual host is not complex, just add the appropriate command to the httpd.conf file.

The following is an example of a name-based (httpd.conf) virtual host (Editor's note: For space reasons, we only give the relevant part, the full text see www.swm.com.cn). IP: 192.168.188.20, two domain names are long.com.cn, short.com.cn respectively.

Httpd.conf:

Namevirtualhost 192.168.188.20

ServerAdmin webmaster@long.com
ServerName www.long.com
Documentroot/home/httpd/long/html

ErrorLog Logs/error_log
Transferlog Logs/access_log


ServerAdmin webmaster@short.com
ServerName www.short.com
Documentroot/home/httpd/short/html
ErrorLog Logs/short.com-error_log
Transferlog Logs/short.com-access_log


The Namevirtualhost command specifies on which IP to set the virtual host

Make specific settings for each host in the VirtualHost command.

The serveradmin command is to set the e-mail sent to the browser when the WWW server executes a problem, so that the user can contact the system administrator with the e-mail serveradmin.

The servername command is to set the WWW server's domain name.

Iv. provide personal homepage space, user homepage settings

Often see some websites to provide personal homepage, look very proud, in fact, you can also open the space on your machine to others, which is very simple to achieve. As long as you follow the instructions below to modify your WWW server configuration file.

To open the user's home page space, one is to determine the user's home page directory, the second is the Open User home page directory Read permissions.

Method One

You as root to user Chen open an account, the system will automatically give Chen allocated a space/home/user, and then in the/home/chen directory to build a public_html subdirectory, subdirectory properties to set to other readable and executable.

Then modify the access.conf. At the end of the file, add the following paragraph:

    
AllowOverride None
Order Allow,deny
Allow from all
    

Then, rerun httpd, the user can visit Chen's personal homepage via http://www.swm.com.cn/~chen/.
The advantage of this method is convenience, the disadvantage is that the security is too poor.

Method Two

Another option is to build a directory for users Chen in the/home/httpd directory Chen. Modify the Userdir in srm.conf to/home/httpd/*/html, then rerun httpd.

< finished full >


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.