In Linux, Apache configures web page access control permissions

Source: Internet
Author: User

In Linux, Apache configures web page access control permissions

The httpd version number in this article is httpd-2.4.4, with Firewall and selinux turned off beforehand.

In Linux, apache needs to modify/etc/httpd to set the web page access control permissions. the conf file must be kept in mind: Once you modify/etc/httpd. conf must restart the httpd service; otherwise, it cannot take effect. (We will not mention this part once we modify the file and restart it on our own) We will mainly Modify/etc/httpd. the content in conf is DocumentRoot "/usr/local/apache/htdocs" Options Indexes FollowSymLinks AllowOverride None Require all granted. the IP address of the local machine is 192.168.20..1 and the IP address of the virtual machine is 192.168.109.40Require all granted: allow all hosts to access Require all deny: deny Access From all Hosts. 1. to implement ip-based access control, you only need to change Require all granted to the Require ip address. For example, if you want to access the ip address 192.168.109.4, you only need to change Require all granted to Require ip 192.168.109.4, when we use a host to access the web page, it means that the ip address 192.168.20..1 has no access permission.
Now we want the host to have access permissions, just add Require ip 192.168.20..1. For example
2. Host Name-Based Access Control because we do not have a DNS server, we need to implement local resolution. Edit the/etc/hosts file. The IP address of our host is 192.168.20..1, the host name is the HXK-PC, add this line of content, as shown in the following figure:
Then modify Require all granted to the Require host HXK-PC. Example: DocumentRoot "/usr/local/apache/htdocs" Options Indexes FollowSymLinks AllowOverride None Require host HXK-PC if Require host HXK-PC, just change a host name www.a.com, because the local host is not this host name, therefore, the following access page appears. 3. User-Based Access Control. For some specific Web pages, we only want to allow access by a specific user through a password, this requires the use of user-based access control this item for the httpd-2.4.4 may have a problem, I did not experiment for a morning and finally found the token. For httpd-2.4.3 to achieve this function first create the user hybripasswd-c-m/usr/local/apache/htpasswd tom (create a tom user) Note: The first create need to add-c, the second time you add a user, you must not add-c and enter the password.
Finally, modify httpd. conf configuration file DocumentRoot "/usr/local/apache/htdocs" Options Indexes FollowSymLinks AllowOverride AuthConfig AuthType Basic AuthName "Restricted Files" AuthUserFile/usr/local/apache/htpasswd Require valid-user note: the path of AuthUserFile is the path of the user just created. If Require valid-user is used, all users in the user file can log on. Require user tom indicates that the tom user in the file just created can log on.
Enter the password to access. 4. group-based Access Control on the premise of 3, create a user htpasswd-m/usr/local/apache/htpasswd jerry because it is group-based, therefore, create the vim/usr/local/apache/groups group and add the group name mygroup: tom jerry finally modifies the configuration file DocumentRoot "/usr/local/apache/htdocs" Options Indexes FollowSymLinks AllowOverride AuthConfig AuthType Basic AuthName "Restricted Files" AuthUserFile/usr/local/apache/htpasswd AuthGroupFile/ usr/local/apache/groups Require group mygroup

Install a Web Server on Ubuntu Server 14.04 (Linux + Apache + MySQL + PHP)

Install and configure the PHP environment in Linux (Apache2)

Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04

Compile and install LAMP in CentOS 5.9 (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12)

Source code for Web server architecture in RedHat 5.4 build the LAMP environment and application PHPWind

Apache details: click here
Apache: click here

This article permanently updates the link address:

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.