httpd-上課內容

來源:互聯網
上載者:User

標籤: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-上課內容

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.