Web Access control for Apache basic services (authentication, virtual directory, virtual host)

Source: Internet
Author: User
Tags fully qualified domain name

Apache HTTP Server is favored by many enterprises, thanks to its code open source, cross-platform, functional modularity, flexible customization and many other advantages, not only stable performance, in the security performance is also very good.
Next we'll build a website with Apache to learn how to access Web sites by creating virtual directory logins, and to set up authentication to improve access security, and to create virtual host access through different domain names.

Next, let's take a look at:
1. Mount the image file and install the HTTP service as shown in:

There is also a conf.d under the path etc/httpd/some virtual directories, virtual hosts, and configuration files based on different port numbers are placed in CONF.D.

2. Enter the HTTP master configuration file, turn on the listening port, change to the local IP, comment out the IPV6, and define the fully qualified domain name as shown:


3. After the configuration file modification is complete, start the service, turn off the firewall, turn off enhanced XXX. As shown in the following:

4. Next, enter the server IP directly on the host browser and you will see the homepage of Apache. As shown in the following:


We write a word "This is Apache test" as a welcome page in this path directory and the browser refreshes it to see:

by command mv/var/www/html/index.html >/var/www/html/index.txt here if we change this home type to a type that the system does not recognize, it will definitely not be accessible!
If you want to access there is also a way, we go into the/etc/httpd/conf/httpd.conf to modify its main configuration file on the line, after Index.html.var continue to add a index.txt on the line.
5. Under Path ETC/HTTPD/CONF.D, edit a new file vdir.conf inside the virtual directory (here the newly edited vdir.conf is in the Master config file etc/httpd/conf/ Httpd.conf can be automatically recognized, the main profile has an include conf.d/*.conf meaning that conf.d contains all files ending with. conf in the relative path)


6. Create a new directory based on the requirements of the above configuration file and restart the service again. Then verify the virtual directory access on the browser. As shown in the following:


7. Just used to create a virtual directory login access, next we turn on authentication for login access. So you need to go to the vdir.conf to make changes. As shown in the following:

8. Create a new user for authentication. As shown in the following:


9. The above is an authentication setting that enhances access security. Next we create two virtual hosts (implementing multiple websites) to access the login. When there are more virtual hosts, it is recommended that you use a separate virtual host configuration file. There are 3 kinds of forms: 1. Different IP 2. Same IP different port 3. Same IP same port different host name. Let's first configure the same IP for the same port with different host names, as shown in:
Create and edit a new configuration file under CONF.D:

Write content:

The DNS service is also installed in the way:

Modify the contents of the configuration file with different host names for the same IP port:

After the 10.DNS service is installed, modify the main configuration file vim/etc/named.conf
To modify a zone configuration file Vim/etc/named.rfc1912.zones

To modify a zone data configuration file:




After the configuration has been modified, start the DNS service: Service named start.

10. Perform different host name access verification. As shown in the following:



11. Next, configure the different ports for login access. As shown in the following:



Down into the HTTP Master config file to add 8080 listening ports:

To view the listening port:


Test success!

Web Access control for Apache basic services (authentication, virtual directory, virtual host)

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.