00 个人建议&常用操作命令 0.1 个人建议 1、关于安装配置由于安装配置过程繁琐,很容易出问题。建议每完成一个完整操作,进行一次快照,防止出现无法解决的问题,可回退到原先不发生错误的系统版本
- 关于虚拟机“快照”操作,请自行百度
建议提前克隆一份干净的虚拟机系统或者快照,便于系统版本回退到不错误的状态,减少重复安装系统操作,浪费时间
0.2 httpd服务操作命令#启动httpd服务 systemctl start httpd.service #停止httpd服务 systemctl stop httpd.service #重启启动httpd服务 systemctl restart httpd.service #查看httpd服务状态 systemctl status httpd.service01 安装Apache服务器 安装步骤
- 查看linux系统服务中有没有httpd
- yum list | grep httpd
说明:界面未出现httpd关键字,证明本系统未安装httpd服务
- 安装httpd服务
yum install httpd
- 查看httpd服务是否安装成功
- rpm -qa |grep httpd
4.配置开机启动
- chkconfig httpd on
5.重启httpd服务
- systemctl restart httpd.service
出现以下界面,表示http服务开启成功
6.启动浏览器,输入ip:http://192.168.175.136/,Apach服务器启动成功
(根据自己的系统修改ip)
- 查看ip:ifconfig
- 查看防火墙状态;systemctl status firewalld
Active状态为running,表明防火墙当前为开启状态
解决办法:关闭Linux系统的防火墙
- 暂时关闭防火墙:systemctl stop firewalld
- 查看防火墙状态;systemctl status firewalld
Active状态为dead,表明防火墙关闭成功
关于防火墙的其他命令:
- 执行开机禁用防火墙自启命令 : systemctl disable firewalld.service - 启动:systemctl start firewalld.service - 防火墙随系统开启启动 : systemctl enable firewalld.service
7.Apache服务器启动成功
主要配置文件为/etc/httpd/conf/httpd.conf
默认配置,可以不用修改
查看主配置文件
- cd /etc/httpd/conf/httpd.conf
修改配置ServerName
-
ServerName localhost:80
修改配置端口 -
Listen 80
配置多种格式文件的默认访问页面
- DirectoryIndex:配置默认访问的页面名称、文件格式,(jsp、php等)
假设配置为 DirectoryIndex: default.html,输入ip/子目录/
会默认访问default.html页面
Web站点主目录为DocumentRoot "var/www/html" ,可以在主目录下创建子目录
DocumentRoot :配置页面默认的访问目录路径
示范案例在Web站点下创建student子目录,student目录下创建index.html页面
1.默认访问的是系统 /var/wwwhtm目录下的资源,cd到当前目录创建子目录和index页面
- cd /var/www/htm
- mkdir student
- vim /student/index.html
2.vim下编辑index.html页面
student-codekiki的个人主页
欢迎进入student-codekiki的个人主页
我和大家一起学习个人网站搭建的学习.


