1.虚拟机上网
1.安装软件(httpd) yum search httpd yum install -y httpd 2.关闭防火墙 [root@localhost ~]# systemctl stop firewalld.service 3.selinux [root@localhost ~]# vim /etc/selinux/config SELINUX=disabled [root@localhost ~]# setenforce 0 //临时关闭selinux 4.启动服务 [root@localhost ~]# systemctl restart httpd 5.验证 [root@localhost ~]# firefox &
问题: 1.首页文件叫什么名字? 2.首页文件存放的位置 3.看一看?在哪里看? 1.找出apache配置文件路径 [root@localhost ~]# rpm -ql httpd | grep conf [root@localhost ~]# vim /etc/httpd/conf/httpd.conf (没有任何修改) 119 DocumentRoot "/var/www/html" 164 DirectoryIndex index.html 2.编写首页文件内容 [root@localhost ~]# vim /var/www/html/index.html 或者 [root@localhost ~]# echo "happy new year" > /var/www/html/index.html
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf 165 DirectoryIndex test.html 166 #DirectoryIndex index.html 119 DocumentRoot "/test" 120 #DocumentRoot "/var/www/html" 132 <Directory "/test"> 133 #<Directory "/var/www/html"> [root@localhost ~]# systemctl restart httpd
实验四:修改端口号(8088)
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf 42 Listen 8088 43 #Listen 80
实验五:用主机名访问
做临时解析 linux: [root@localhost ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.1.134 www.qq1.com windows: C:\Windows\System32\drivers\etc\hosts 192.168.1.134 www.qq1.com
实验六:虚拟主机
实验七:用https访问网站
实验八:动态页面
作业
1.环境配置好:网络、yum 2.完成一个实验 自定义首页文件路径为:/qwer/qaz 自定义首页文件名称:qq.qz 指定端口号为9000