LAMP--Apache 使用者認證

來源:互聯網
上載者:User

標籤:apache   使用者認證   

      在日常管理過程中,不免有些特殊的訪問,為了增加安全,可以給它設定一個使用者認證機制。比如discuz論壇,它的管理後台本身就有密碼,但為了更加安全,可以設定一層使用者認證,讓某些目錄不能被隨意訪問。

[[email protected] ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf

       在對應的虛擬機器主機配置中加入如下配置:

<VirtualHost *:80>    DocumentRoot "/data/www"    ServerName www.123.com  <Directory /data/www/admin.php>  AllowOverride AuthConfig  AuthName "Please input the passwd"  AuthType Basic  AuthUserFile /data/.htpasswd  require valid-user  </Directory></VirtualHost>

       說明:首先指定對哪個目錄進行驗證,AuthName 自訂,顯示在輸入密碼框的伺服器提示欄,AuthUserFile 指定使用者密碼檔案在哪裡。

       建立進行驗證的使用者,首次建立需要 -c 選項,目的是為了建立/data/.htpasswd 這個檔案,再次建立不能加-c,否則會把之前的覆蓋掉。斷行符號輸入設定的密碼。

[[email protected] ~]# /usr/local/apache2/bin/htpasswd -c /data/.htpasswd testNew password:Re-type new password:Adding password for user test

        重啟apache服務

[[email protected] ~]# /usr/local/apache2/bin/apachectl -tSyntax OK[[email protected] ~]# /usr/local/apache2/bin/apachectl graceful

       這裡用 graceful 相當於是 reload 配置。


本文出自 “散宜生的學習筆記” 部落格,請務必保留此出處http://sanyisheng.blog.51cto.com/11154168/1795799

LAMP--Apache 使用者認證

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.