4、建立httpd服務器(基于編譯的方式進行),要求: 提供兩個基于名稱的虛擬主機: (a)www1.stuX.com,頁面文件目錄為/web/vhosts/www1;錯誤日志為/var/log/httpd/www1.err,訪問日志為/var/log/httpd/www1.access; (b)www2.stuX.com,頁面文件目錄為/web/vhosts/www2;錯誤日志為/var/log/httpd/www2.err,訪問日志為/var/log/httpd/www2.access; (c)為兩個虛擬主機建立各自的主頁文件index.html,內容分別為其對應的主機名; (d)通過www1.stuX.com/server-status輸出httpd工作狀態相關信息,且只允許提供帳號密碼才能訪問(status:status); 啟用虛擬主機需要將中心主機禁用: 并啟用:NameVirtualHost *:80 這里實驗出現一點問題,在DocumentRoot中的文件路徑修改的時候,Directory沒有進行更改,在給出沒有確定網址的時候,會跳轉至系統默認的歡迎頁面,這里需要注意的是:Directory在全局定義的時候對虛擬主機是不生效的,需要在虛擬主機中重新進行定義; 現在基本配置完成: <VirtualHost 172.16.0.3:80> ServerName www1.stuX.com DocumentRoot "/wanghongkai/web1/host" ErrorLog "/var/log/www1.err" CustomLog "/var/log/www1.access" common </VirtualHost> <VirtualHost 172.16.0.3:80> ServerName www2.stuX.com DocumentRoot "/wanghongkai/web2/host" ErrorLog "/var/log/www1.err" CustomLog "/var/log/www1.access" common </VirtualHost> 基于認證模式訪問內置的頁面server-status <VirtualHost 172.16.0.3:80> ServerName www1.stuX.com DocumentRoot "/wanghongkai/web1/host" ErrorLog "/var/log/www1.err" CustomLog "/var/log/www1.access" common <Location /server-status> AuthType Basic AuthName "only for Admin" AuthUserFile /etc/httpd/conf.d/.htpasswd SetHandler server-status Require valid-user </Location> </VirtualHost> <VirtualHost 172.16.0.3:80> ServerName www2.stuX.com DocumentRoot "/wanghongkai/web2/host" ErrorLog "/var/log/www1.err" CustomLog "/var/log/www1.access" common </VirtualHost> #<VirtualHost 172.16.0.3:80> # ServerName www1.stuX.com # DocumentRoot "/wanghongkai/web1/host" #</VirtualHost> 5、為第4題中的第2個虛擬主機提供https服務,使得用戶可以通過https安全的訪問此web站點; (1)要求使用證書認證,證書中要求使用的國家(CN)、州(HA)、城市(ZZ)和組織(MageEdu); (2)設置部門為Ops,主機名為www2.stuX.com,郵件為admin@stuX.com; 1,按照/etc/pki/tls/openssl.conf配置文件創建serial和index.txt文件 2,生成CA的私鑰文件: [root@ns1 CA]# (umask 077; openssl genrsa -out private/cakey.pem 2048) 3,生成公鑰文件: [root@ns1 CA]# openssl req -x509 -new -key private/cakey.pem -days 7300 -out cacert.pem You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:CN State or Province Name (full name) []:HA Locality Name (eg, city) [Default City]:ZZ Organization Name (eg, company) [Default Company Ltd]:Magf^C [root@ns1 CA]# openssl req -x509 -new -key private/cakey.pem -days 7300 -out cacert.pem You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:CN State or Province Name (full name) []:HA Locality Name (eg, city) [Default City]:ZZ Organization Name (eg, company) [Default Company Ltd]:MageEdu Organizational Unit Name (eg, section) []:Ops Common Name (eg, your name or your server's hostname) []:ca.Mageud.com Email Address []:admin@magedu.com 4,進入客戶端進入/etc/httpd目錄下創建ssl目錄生成公鑰文件和私鑰文件: [root@ns2 ssl]# (umask 077; openssl genrsa -out httpd.key 2048) [root@ns2 ssl]# openssl req -new -key httpd.key -days 365 -out httpd.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:CN State or Province Name (full name) []:HA Locality Name (eg, city) [Default City]:ZZ Organization Name (eg, company) [Default Company Ltd]:MageEdu Organizational Unit Name (eg, section) []:Ops Common Name (eg, your name or your server's hostname) []:www.stux.com Email Address []:admin@stux.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: 5,將申請發送給CA認證機構: 6,CA主機對證書進行簽發: [root@ns1 CA]# openssl ca -in /tmp/httpd.csr -out /etc/pki/CA/newcerts/httpd.crt -days 365 Using configuration from /etc/pki/tls/openssl.cnf Check that the request matches the signature Signature ok Certificate Details: Serial Number: 1 (0x1) Validity Not Before: Sep 23 18:31:40 2016 GMT Not After : Sep 23 18:31:40 2017 GMT Subject: countryName = CN stateOrProvinceName = HA organizationName = MageEdu organizationalUnitName = Ops commonName = www.stux.com emailAddress = admin@stux.com X509v3 extensions: X509v3 Basic Constraints: CA:FALSE Netscape Comment: OpenSSL Generated Certificate X509v3 Subject Key Identifier: 89:AA:21:62:10:CA:AE:E6:A9:08:36:88:19:DF:25:23:8E:84:C8:4B X509v3 Authority Key Identifier: keyid:75:F9:01:4A:B9:6F:7E:6B:1B:6B:BE:FC:4A:19:E6:09:44:75:CE:C6 Certificate is to be certified until Sep 23 18:31:40 2017 GMT (365 days) Sign the certificate? [y/n]:y 1 out of 1 certificate requests certified, commit? [y/n]y Write out database with 1 new entries Data Base Updated 7,將證書發還給客戶端: [root@ns1 CA]# scp /etc/pki/CA/newcerts/httpd.crt root@172.16.0.4:/etc/httpd/ssl/
原創文章,作者:wostop,如若轉載,請注明出處:http://www.www58058.com/51802
請完成題目要求所有細節所要求的知識點