一.httpd-2.2版本安裝及配置
創(chuàng)新互聯(lián)建站是一家集網(wǎng)站建設(shè),高臺(tái)企業(yè)網(wǎng)站建設(shè),高臺(tái)品牌網(wǎng)站建設(shè),網(wǎng)站定制,高臺(tái)網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,高臺(tái)網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
1.安裝httpd-2.2.3
# yun -y install httpd
2.查看httpd安裝生成的文件
# rpm -ql httpd | less
3.啟動(dòng)服務(wù)
# service httpd start
4.開機(jī)自動(dòng)啟動(dòng)服務(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"
Options none
AllowOverride None
Order deny,allow
Deny from 192.168.0.1 172.16.100.177
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.虛擬主機(jī)的配置
首先要注釋中心主機(jī) DocumentRoot
20.在/etc/httpd/conf.d/目錄下建立虛擬機(jī)配置文件
# vim /etc/httpd/conf.d/virtual.conf
NameVirtualHost 172.16.100.1:80
ServerName www.luochen.com DocumentRoot "/web/luochen" CustomLog /var/log/httpd/luochen/access_log combined Options none AllowOverride AuthConfig AuthType Basic AuthName "Restricted Files" AuthUserFile "/etc/httpd/conf/htpasswd" Require valid-user 或 Require user hadoop
ServerName www.luo.com DocumentRoot "/web/luo" CustomLog /var/log/httpd/luo/access_log combined Options none AllowOverride None Order deny,allow Deny from 192.168.0.1 172.16.100.177
21.編輯windows下的hosts文件
172.16.100.1 www.luochen.com
172.16.100.1 www.luo.com
22.安裝mod_ssl模塊(htppd基于rpm包安裝時(shí))
# yum -y install mod_ssl
23.查看mod_ssl安裝生成那些文件
# rpm -ql mod_ssl
24.自建CA (在172.16.100.10主機(jī)上)
# 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主機(jī)上)
# mkdir /etc/httpd/ssl
# (umask 077; openssl genrsa 2048 > httpd.key) //生成密鑰
# openssl req -new -key httpd.key -out httpd.csr //生成證書頒發(fā)請(qǐng)求
hostname === ServerName
# scp http.csr 172.16.100.10:/tmp //將證書頒發(fā)請(qǐng)求復(fù)制到服務(wù)器端
29.在172.16.100.10主機(jī)上
# openssl ca -in /tmp/httpd.csr -out /tmp/httpd.crt -daya 3650 //生成證書
# cat /etc/pki/CA/serial //顯示02即成功
30.將證書復(fù)制到客戶端主機(jī)上(172.16.100.1)
# scp 172.16.100.10/tmp/httpd.crt ./ //將證書復(fù)制到客戶端主機(jī)上
31.刪除tmp目錄下所有文件
# vim rm -rf ./*
32.編輯/etc/httpd/conf.d/ssl.conf 文件(172.16.100.1)
# vim /etc/httpd/conf.d/ssl.conf
ServerName www.luochen.com
DocumentRoot "/web/www/luochen"
SSLCertificateFile /etc/httpd/ssl/httpd.crt
SSLCertificateKeyFile /etc/httpd/ssl/httpd.key
33.重啟httpd服務(wù)器
# service httpd restart
34.將CA的證書復(fù)制到windows主機(jī)上
/etc/pki/CA/cacert.pem //在172.16.100.10
35.在Windows主機(jī)上對(duì)證書進(jìn)行重命名
cacert.pem cacert.crt
36.雙擊安裝證書
37.最后在瀏覽器用https協(xié)議訪問 驗(yàn)證