標籤:httpd
設定檔:/etc/httpd/conf/httpd.conf
<IfModule dir_module> DirectoryIndex index.html text.html #此處會優先讀取前面一個檔案。如果index檔案不存在,就讀取text檔案。如果都沒有,顯示測試頁 </IfModule>
/etc/httpd/conf.d/*.conf conf.d目錄下的所有conf檔案
虛擬機器主機
基於主機名稱:
<VirtualHost *:80> ServerName localhost.localdomain DocumentRoot /var/www/local</VirtualHost>
添加欄位,控制檔案存取權限:
建立2個使用者(不是系統使用者,是訪問html的使用者)
[[email protected] conf]# htpasswd -c /etc/httpd/.htpasswd user1New password: Re-type new password: Adding password for user user1[[email protected] conf]# htpasswd /etc/httpd/.htpasswd user2New password: Re-type new password: Adding password for user user2[[email protected] conf]# cat /etc/httpd/.htpasswd user1:$apr1$/HcTzDUm$16tL9pldhS4YV7i1E6GKU0user2:$apr1$qTaxMLFd$1YtqCEglB1e5lNyjUbuec1
<VirtualHost *:80> ServerName localhost.localdomain DocumentRoot /var/www/local <Directory /var/www/local> AuthType basic AuthName "Please Input Your Name&Passwd!" AuthUserFile /etc/httpd/.htpasswd Require user user1 #只有user1能訪問 Require valid-user #.htpasswd中的使用者都能訪問 </Directory> </VirtualHost>
以索引的方式顯示檔案,並且可以顯示連結檔案
<Directory /var/www/local/file> Options Indexes FollowSymlinks </Directory>
Options -Indexes -FollowSymlinks #要關閉功能在前面加上-
添加IP限制
<Directory /var/www/local/allow> Order allow,deny ##後面的優先順序高!!如果allow在後面,allow的優先順序高 allow from 10.42.1.0/24 deny from 10.42.1.14 </Directory>
https
預設連接埠:443
安裝包:mod_ssl
ssl的設定檔
/etc/httpd/conf.d/ssl.conf
Listen 443<VirtualHost *:443> ServerName localhost.localdomain DocumentRoot /var/www/ssl SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 SSLCertificateFile /etc/pki/tls/certs/localhost.crt #服務端的認證 SSLCertificateKeyFile /etc/pki/tls/private/localhost.key #服務端的私密金鑰 SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt #CA的認證</VirtualHost>
不要CA的認證,自己簽名
[[email protected] certs]# lsca-bundle.crt localhost.crt Makefileca-bundle.trust.crt make-dummy-cert renew-dummy-cert[[email protected] certs]# pwd/etc/pki/tls/certs[[email protected] certs]# make my.crt
產生一個私密金鑰(需要輸入密碼),
產生一個公開金鑰(認證)(需要輸入私密金鑰的密碼)。
然後填寫認證的資訊(#主機名稱#)
httpd-上課內容