Linux中Apache服务器的简单配置

配置Apache服务器:

1.安装Apache,可以参考Linux 中yum的配置来安装:

yum install http* -y

2.修改SELinux:

setenforce 0

查看:

3.防火墙开放httpd服务

firewall-cmd --permanent --add-service=httpd

重启防火墙:

firewall-cmd --reload

查看防火墙:

firewall-cmd --list-all

4.修改Apache服务器的配置

 新建测试文件:

vim /etc/httpd/conf.d/test.conf
<Virtualhost *:80>
        ServerName server0.example.com
        DocumentRoot /var/www/html 
</Virtualhost>

其中:

  ServerName 为域名

  DocumentRoot 为html主页的路径

5.创建一个html文件

/var/www/html/index.html
<html >
<head>
    <title>页面导航</title>
    <style type="text/css">
        *{ margin:0; padding:0}
        //#id ul{  border: 2px solid red;}
        #id ul{ list-style-type:none; margin:0 auto;600px }
        #id ul li{  float:left; 100px; text-align:center }
        #id ul li a{ color:teal ; background-color:Aqua; display:inline-block;100px; line-height:30px ; text-decoration:none}
        #id ul li a:hover{  background-color:Blue; color:White; font-style:oblique; font-weight:bold; text-decoration:underline }
    </style>
</head>
<body>
<div id="id">
    <ul>
        <li><a href="#">首页</a></li>
        <li><a href="#">探索百科</a></li>
        <li><a href="#">用户</a></li>
        <li><a href="#">任务</a></li>
        <li><a href="#">合作</a></li>
        <li><a href="#">知识商城</a></li>
    </ul>
</div>
</body>
</html>

6.启动http服务

systemctl start httpd

开机自启动:

systemctl enable httpd

 7.在windows下访问该网页

其中地址为服务器端的地址

版权

作者:feiquan

出处:http://www.cnblogs.com/feiquan/

版权声明:本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

大家写文都不容易,请尊重劳动成果~ 这里谢谢大家啦(*/ω\*)

原文地址:https://www.cnblogs.com/feiquan/p/9236714.html