一、虛擬主機 A、基於IP地址 B、基於功能變數名稱 C、基於埠號 複習yum倉庫掛載 mkdir /media/cdrom mount /dev/cdrom /media/cdrom/ vim /etc/fstab /dev/cdrom /media/cdrom iso9960 defaults 0 0 ...
一、虛擬主機
A、基於IP地址 B、基於功能變數名稱 C、基於埠號
複習yum倉庫掛載
mkdir /media/cdrom
mount /dev/cdrom /media/cdrom/
vim /etc/fstab
/dev/cdrom /media/cdrom iso9960 defaults 0 0
vim /etc/yum.repos.d/rhel7.repo
yum install httpd
systemctl restart httpd
systemctl enable httpd
vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
systemctl restart network
基於IP地址
mkdir -p /home/wwwroot/10
mkdir -p /home/wwwroot/20
mkdir -p /home/wwwroot/30
echo "1111111" > /home/wwwroot/10/index.html
echo "2222222" > /home/wwwroot/20/index.html
echo "3333333" > /home/wwwroot/30/index.html
vim /etc/httpd/conf/httpd.conf
systemctl restart httpd
ls -lZd /var/www/html/
semanage fcontext -at httpd_sys_content_t /home/wwwroot
semanage fcontext -at httpd_sys_content_t /home/wwwroot/10
semanage fcontext -at httpd_sys_content_t /home/wwwroot/20
semanage fcontext -at httpd_sys_content_t /home/wwwroot/30
semanage fcontext -at httpd_sys_content_t /home/wwwroot/10/*
semanage fcontext -at httpd_sys_content_t /home/wwwroot/20/*
semanage fcontext -at httpd_sys_content_t /home/wwwroot/30/*
restorecon -Rv /home/wwwroot/
基於功能變數名稱
mkdir -p /home/wwwroot/www
mkdir -p /home/wwwroot/bbc
mkdir -p /home/wwwroot/tech
echo "wwwwwwwww" > www/index.html
echo "bsbbbbbsbs" > bbs/index.html
echo "techtechtech" > tech/index.html
vim /etc/hosts
ls -lZd /var/www/html (查看預設網站下許可權)
添加基於功能變數名稱虛擬主機許可權
semanage fcontext -at httpd_sys_content_t /home/wwwroot
semanage fcontext -at httpd_sys_content_t /home/wwwroot/www
semanage fcontext -at httpd_sys_content_t /home/wwwroot/www/*
semanage fcontext -at httpd_sys_content_t /home/wwwroot/bbc
semanage fcontext -at httpd_sys_content_t /home/wwwroot/bbc/*
semanage fcontext -at httpd_sys_content_t /home/wwwroot/tech
semanage fcontext -at httpd_sys_content_t /home/wwwroot/tech/*
restorecon -Rv /home/wwwroot/ (使配置生效)
基於埠號
mkdir -p /home/wwwroot/8555
mkdir -p /home/wwwroot/8666
echo "8555555555555" > /home/wwwroot/8555/index.html
echo "8666666666666" > /home/wwwroot/8666/index.html
semanage port -l | grep http (查看關於httpd服務相關埠號)
semanage port -at http_port_t -p tcp 8555
semanage port -at http_port_t -p tcp 8666
systemctl restart httpd
systemctl enable httpd
ls -lZd /var/www/html
semanage fcontext -at httpd_sys_content_t /home/wwwroot
semanage fcontext -at httpd_sys_content_t /home/wwwroot/8555
semanage fcontext -at httpd_sys_content_t /home/wwwroot/8555/*
semanage fcontext -at httpd_sys_content_t /home/wwwroot/8666
semanage fcontext -at httpd_sys_content_t /home/wwwroot/8666/*
restorecon -Rv /home/wwwroot/
Apache訪問控制
yum install httpd
systemctl restart httpd
systemctl enable httpd
iptables -F
service iptables save
echo "weclcom to rise-house" > /var/www/html/server/index.html
systemctl restart httpd