http基本配置
2021/8/17 23:06:48
本文主要是介绍http基本配置,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1.要求搭建web服务器,能够访问到网页内容为“小胖,你咋这么胖呢!” 在图形化界面,更改手动模式,添加IP地址
![](/upload/202108/17/202108172306464233.png)
![](/upload/202108/17/202108172306472700.png)
下一步 [root@localhost ~]# rpm -qa | grep httpd #查看是否有http的包
[root@localhost ~]# yum install httpd #如果没有http的包,则需先下载http [root@localhost ~]# systemctl stop firewalld #关闭防火墙 [root@localhost ~]# setenforce 0 #临时关闭seLinux [root@localhost ~]# systemctl start httpd #启动http服务器 [root@localhost ~]# vim /etc/httpd/conf.d/vhost.conf #更改配置信息
[root@localhost ~]# systemctl restart httpd [root@localhost ~]# mkdir /130 /131 [root@localhost ~]# echo "小胖。你咋这么胖呢!" > /130/index.html [root@localhost ~]# cat /130/index.html 小胖。你咋这么胖呢!
2.要求搭建web服务器,创建基于域名的虚拟主机,能够使用www.xiaopang.com和www.daqiang.com访问各自的网站网站存放路径分别为/xiaopang和/daqiang,内容自定。
[root@localhost ~]# rpm -qa | grep httpd #查看是否有http的包 [root@localhost ~]# yum install httpd #如果没有http的包,则需先下载http [root@localhost ~]# systemctl stop firewalld #关闭防火墙 [root@localhost ~]# setenforce 0 #临时关闭seLinux [root@localhost ~]# systemctl start httpd #启动http服务器 [root@localhost ~]# vim /etc/httpd/conf.d/vhost.conf #更改配置信息 yum包安装如下: [root@localhost ~]# vim /etc/yum.repos.d/suibian.repo [root@localhost ~]# mount /dev/sr0 /mnt [root@localhost ~]# yum install httpd -y [root@localhost ~]# yum install httpd
更改配置信息
<virtualhost 192.168.126.130:80> DocumentRoot /xiaopang ServerName www.xiaopang.com </virtualhost> <Directory /xiaopang> AllowOverride none Require all granted </Directory> <virtualhost 192.168.126.131:80> DocumentRoot /daqang ServerName www.daqang.com </virtualhost> <Directory /daqang> AllowOverride none Require all granted </Directory> ~ ~ :wq 保存退出
下一步
[root@localhost ~]# systemctl restart httpd [root@localhost ~]# vim /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.126.130 www.xiaopang.com 192.168.126.131 www.daqang.com ~ :wq 保存退出
下一步
在windows下,手动修改host文件
下一步
[root@localhost conf.d]# echo "小明同学,你好" > /xiaopang/index.hml [root@localhost conf.d]# echo "小红同好,你好" > /daqang/index.html [root@localhost conf.d]# cat /xiaopang/index.html 小明同好,你好 [root@localhost conf.d]# cat /daqang/index.html 小红同好,你好 [root@localhost conf.d]# curl http://www.xiaopang.com 小明同好,你好 [root@localhost conf.d]# curl http://www.daqang.com 小红同好,你好
最后在浏览器中输入网址
这篇关于http基本配置的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26结对编程到底难不难?答案在这里
- 2024-06-19《2023版Java工程师》课程升级公告
- 2024-06-15matplotlib作图不显示3D图,怎么办?
- 2024-06-1503-Loki 日志监控
- 2024-06-1504-让LLM理解知识 -Prompt
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现
- 2024-06-03为什么以及如何要进行架构设计权衡?
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)