Protect the Apache website in Linux-Linux Enterprise Application-Linux server application information. For more information, see the following section. The wide application and rapid development of Linux have benefited from the rapid development of the Internet. Linux is outstanding for Web services that are widely used on the Internet. It is hard to tell how many websites on the Internet are using the Linux system, but the use of Apache servers in many websites undoubtedly occupies a huge market share.
How can we protect websites from illegal user login? Generally, you can use the identity authentication method. Identity Authentication is an effective way to prevent unauthorized users from using resources and an effective way to manage registered users. Currently, many websites use identity authentication to manage user resources and impose strict restrictions on user access permissions. The traditional identity authentication method checks the user's registration name and password to determine whether to allow the user to use resources. However, this authentication method is not very effective in some cases. Especially on the Linux platform, the Apache server can use the Linux method to implement password verification and protection.
In Linux, the most common password protection method is to use the. htaccess file, that is, the directory configuration, to implement password protection, which is also one of the features of the. htaccess file. This method prevents unauthorized viewers from entering the restricted area set by the. htaccess file. Generally, it is too simple to use JavaScript to set passwords, which can be easily cracked, resulting in insecurity. Using. htaccess files to protect directories is more effective and secure than using other programs (Java/HTML/ASP/CGI. More importantly, you can set it using. htaccess without programming. The specific operation is easier.
The following describes and demonstrates how to implement password protection in Linux + Apache to fully implement website protection.
What Is A. htaccess file?
The. htaccess file is a configuration file on the Apache server. It is a text file that can be written in any text editor .. The htaccess file provides a method for changing the configuration of directories, that is, by placing a file containing one or more commands in a specific document directory (. to apply to this directory and all its subdirectories .. The htaccessfunction is used to set the web page password. When an error occurs, the current file name (such as index.html) of the first page is changed, the file name cannot be read, the file is redirected, the MIME category is added, and the files under the column directory are prohibited.
When you need to change the server configuration for the directory without the root permission for the server system, you should use the. htaccess file. If the server administrator is unwilling to modify the configuration frequently, the user can pass. the htaccess file is used to modify the configuration by itself, especially when the ISP provides multiple user sites on one machine, and you want to change the configuration by yourself, the part is usually open. the htaccess function is set for the user.
Note that. htaccess is a complete file name, not ***. htaccess or other format (of course, some administrators set it to another name, but generally use. htaccess ). In addition, when uploading a. htaccess file, you must use asc ii mode and use the chmod command to change the permission to 644 (rw_r1_r __). Each directory and sub-directory containing. htaccess will be affected by. htaccess. For example,. htaccess file, so all the files in/abc/AND/abc/def/will be affected by it, but/index.html will not be affected, this is very important.
Implement password protection
1. Create a. htpasswd File
First, create a file under the directory (such as htdocs) where you want to set access control. You can set the file name on your own. Generally, the server will set it to. htpasswd, which cannot be read by HTTP .. Each row in the htpasswd file represents a user. The user's name and encrypted password are separated by colons.
2. implement protection for. htaccess files
The content of the. htaccess file is as follows: