您好,登錄后才能下訂單哦!
一.httpd-2.2版本安裝及配置
1.安裝httpd-2.2.3
# yun -y install httpd
2.查看httpd安裝生成的文件
# rpm -ql httpd | less
3.啟動服務(wù)
# service httpd start
4.開機自動啟動服務(wù)
# chkconfig --add httpd
# chkconfig --level 345 httpd on
5.建立測試頁面
# cd /var/www/html
# vim index.html
6.httpd服務(wù)的配置文件
# cd /etc/httpd/conf/
# cp httpd.conf httpd.conf.bak
7.編輯配置文件
# vim httpd.conf
ServerTokens Major
KeepAlive On
8.修改網(wǎng)站根目錄
DocumentRoot "/web/html"
<Directory "/web/html">
Options none
AllowOverride None
Order deny,allow
Deny from 192.168.0.1 172.16.100.177
<Directory/>
9.檢測配置文件是否語法正確
# httpd -t
10.linux下使用純文本瀏覽器
# elinks http://ip
11.限定用戶訪問網(wǎng)站
AllowOverride AuthConfig
AuthType Basic
AuthName "Restricted Files"
AuthUserFile "/etc/httpd/conf/htpasswd"
Require valid-user 或 Require user hadoop
12.建立限定用戶文件
# htpasswd -c -m /etc/httpd/conf/htpasswd hadoop
# htpasswd -m /etc/httpd/conf/htpasswd tom
13.重啟服務(wù)
# service httpd restart
14.在電腦瀏覽器上測試是否設(shè)置成功(限定用戶)
15.基于組限定訪問
AllowOverride AuthConfig
AuthType Basic
AuthName "Restricted Files"
AuthUserFile "/etc/httpd/conf/htpasswd"
AuthGroupFile "/etc/httpd/conf/htgroup"
Require group myusers
16.建立用戶組文件
# vim /etc/httpd/conf/htgroup
myusers: hadoop tom
17.重啟服務(wù)
# service httpd restart
18.htpasswd命令刪除用戶
# htpasswd -D hadoop
19.虛擬主機的配置
首先要注釋中心主機 DocumentRoot
20.在/etc/httpd/conf.d/目錄下建立虛擬機配置文件
# vim /etc/httpd/conf.d/virtual.conf
NameVirtualHost 172.16.100.1:80
<VirtualHost 172.16.100.1:80〉
ServerName www.luochen.com
DocumentRoot "/web/luochen"
CustomLog /var/log/httpd/luochen/access_log combined
<Directory "/web/luochen">
Options none
AllowOverride AuthConfig
AuthType Basic
AuthName "Restricted Files"
AuthUserFile "/etc/httpd/conf/htpasswd"
Require valid-user 或 Require user hadoop
<Directory/>
</VirtualHost>
<VirtualHost 172.16.100.1:80〉
ServerName www.luo.com
DocumentRoot "/web/luo"
CustomLog /var/log/httpd/luo/access_log combined
<Directory "/web/luo">
Options none
AllowOverride None
Order deny,allow
Deny from 192.168.0.1 172.16.100.177
<Directory/>
</VirtualHost>
21.編輯windows下的hosts文件
172.16.100.1 www.luochen.com
172.16.100.1 www.luo.com
22.安裝mod_ssl模塊(htppd基于rpm包安裝時)
# yum -y install mod_ssl
23.查看mod_ssl安裝生成那些文件
# rpm -ql mod_ssl
24.自建CA (在172.16.100.10主機上)
# cd /etc/pki/CA
# (umask 077; openssl genrsa -out private/cakey.pem 2048; )
# vim /etc/pki/tls/openssl.cnf
[ req_distinguished_name ]
countryName_Default = CN
setOrProvinceName_default = HB
localityName_default = WUHAN
0.organizationName_default = COLLEGE
organizationalUnitName_default = Tech
25.# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 3650
hostname ca.luochen.com
26.編輯openssl文件
dir = /etc/pki/CA
27.創(chuàng)建相應(yīng)的目錄文件
# mkdir certs newcerts crl
# touch index.txt
# echo 01 > serial
28.在httpd服務(wù)目錄下創(chuàng)建ssl目錄(在172.16.100.1主機上)
# mkdir /etc/httpd/ssl
# (umask 077; openssl genrsa 2048 > httpd.key) //生成密鑰
# openssl req -new -key httpd.key -out httpd.csr //生成證書頒發(fā)請求
hostname === ServerName
# scp http.csr 172.16.100.10:/tmp //將證書頒發(fā)請求復(fù)制到服務(wù)器端
29.在172.16.100.10主機上
# openssl ca -in /tmp/httpd.csr -out /tmp/httpd.crt -daya 3650 //生成證書
# cat /etc/pki/CA/serial //顯示02即成功
30.將證書復(fù)制到客戶端主機上(172.16.100.1)
# scp 172.16.100.10/tmp/httpd.crt ./ //將證書復(fù)制到客戶端主機上
31.刪除tmp目錄下所有文件
# vim rm -rf ./*
32.編輯/etc/httpd/conf.d/ssl.conf 文件(172.16.100.1)
# vim /etc/httpd/conf.d/ssl.conf
<VirtualHost 172.16.100.1:443>
ServerName www.luochen.com
DocumentRoot "/web/www/luochen"
SSLCertificateFile /etc/httpd/ssl/httpd.crt
SSLCertificateKeyFile /etc/httpd/ssl/httpd.key
</VirtualHost>
33.重啟httpd服務(wù)器
# service httpd restart
34.將CA的證書復(fù)制到windows主機上
/etc/pki/CA/cacert.pem //在172.16.100.10
35.在Windows主機上對證書進行重命名
cacert.pem cacert.crt
36.雙擊安裝證書
37.最后在瀏覽器用https協(xié)議訪問 驗證
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。