httpd 2.2 httpd-vhosts

(1)iptables -F

(2)chcon -R -t httpd_sys_content_t /web/vhosts/*

(4)编辑httpd.conf

#NameVirtualHost *:80前的注释去掉

加Include /etc/httpd/vhosts/stu1.conf

加Include /etc/httpd/vhosts/stu1.conf

(4)vim /etc/hosts 192.168.179.137

www1.stuX.com www2.stuX.com

(5)mkdir /web/vhosts/{www1,www2} -pv

(6)mkdir /var/log/httpd/{www1,www2} -pv

(7)echo “the is www1” > /web/vhosts/www1/index.html

(8)echo “the is www2” > /web/vhosts/www2/index.html

(9)iptables -F

(10)htpasswd -c -b /etc/httpd/.stuX.users tom inspur

(11)htpasswd -b -m /etc/httpd/.stuX.users jerry inspur

(12)

vim / etc/httpd/vhosts/stu1.conf

#在文件中添加如下内容

<VirtualHost *:80>

DocumentRoot /web/vhosts/www1/

ServerName www1.stuX.com

ErrorLog logs/www1/error_log

CustomLog logs/www1/access_log common

<Directory “/web/vhosts/www1”>

options none

allowoverride none

order allow,deny

allow from all

deny from 192.168.1.0/24

</Directory>

<Location /server-status>

SetHandler server-status

AuthType basic

AuthName “Admin area, plz enter username and password “

AuthUserFile “/etc/httpd/.stuX.users “

Require valid-user

</Location>

</VirtualHost>

 

vim etc/httpd/vhosts/stu2.conf

<VirtualHost *:80>

ServerAdmin webmaster@stuX.com

DocumentRoot /web/vhosts/www2/

ServerName www2.stuX.com

ErrorLog logs/www2/error_log

CustomLog logs/www2/access_log common

<Directory “/web/vhosts/www2”>

options none

allowoverride none

order allow,deny

allow from all

</Directory>

</VirtualHost>

 

https

(1)yum install mod_ssl -y

(2)编辑conf.d/ssl.conf

SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES

SSLProxyCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES

SSLHonorCipherOrder on

SSLProtocol all -SSLv3

SSLProxyProtocol all -SSLv3

<VirtualHost _default_:443>

DocumentRoot “/web/vhosts/www2/”

ServerName www2.stuX.com

ErrorLog “/var/log/httpd/www2/error_log”

CustomLog “/var/log/httpd/www2/access_log” common

SSLEngine on

SSLCertificateFile “/etc/httpd/vhosts/ssl/httpd.crt”

SSLCertificateKeyFile “/etc/httpd/vhosts/ssl/httpd.key”

SSLCACertificateFile “/etc/httpd/vhosts/ssl/httpd.crt”

</VirtualHost>

—————————————————————————————————————————————————————————————————-

如果网页目录修改了,要修改selinux安全上下文

修改selinux安全上下文

semanage fcontext -a -t httpd_sys_content_t /var/www/html
semanage fcontext -a -t httpd_sys_content_t /var/www/html/*
restorecon -Rv /var/www/html