安装Apache前需要配置的内容在上一篇文章
安装Apache相关软件
[root@centos ~]# rpm -q httpd
[root@centos ~]# mkdir /iso
[root@centos ~]# mount /dev/cdrom /iso
[root@centos ~]# yum clean all
[root@centos ~]# yum install httpd -y
[root@centos ~]# yum install firefox -y
[root@centos ~]# rpm -qa|grep httpd
启动或重新启动、停止Apache服务
[root@centos ~]# systemctl start/restart/stop httpd
使用防火墙命令,放行http服务
[root@centos ~]# firewall-cmd --list-all
[root@centos ~]# firewall-cmd --permanent --add-service=http
success
[root@centos ~]# firewall-cmd --reload
success
[root@centos ~]# firewall-cmd --list-all
更改当前的SELinux值
[root@centos ~]# setenforce 0
[root@centos ~]# getenforce
Permissive
测试httpd服务是否安装成功 网址跳转后可关闭
[root@centos ~]# systemctl start httpd
[root@centos ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@centos ~]# firefox http://127.0.0.1
当前网站普遍的首页面名称是index.html 因此可以向/var/www/html目录中写入一个文件 会立即生效:
[root@centos ~]# echo "Welcome To MyWeb" > /var/www/html/index.html
[root@centos ~]# firefox http://127.0.0.1
本机可直接跳转 网络卡可直接打开火狐浏览器搜索网址
客户端直接打开浏览器搜索www.long60.cn