linux 学习第十四天(Apache安装、基于ip、基于域名、基于端口配置)
一、虚拟主机
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
下一篇: seo并非网络营销推广的唯一手段分析