apache     80端口,是一个web服务,使用HTTP协议,超文本协议。     HTTPS:43端口他的解析过程和DNS服务类似。1.安装apache[root@dns named]# yum install httpd* -yhttpd-manual.noarch 0:2.4.6-17.el7     #这个包是一个Apache手册 /etc/httpd/conf/httpd.conf          #Apache的配置文件# See URL:http://httpd.apache.org/docs/2.4/ for detailed information.     #Apache官方文档ServerRoot “/etc/httpd”     #安装路径#Listen 12.34.56.78:80Listen 80                    #使用端口Include conf.modules.d/.conf     #加载模块User apache                  #Apache的所属用户Group apache                 #Apache的所属组ServerAdmin root@localhost          #管理员邮件#ServerName www.example.com:80          #网页名(必须是可解析)                          #目录容器    AllowOverride none    Require all deniedDocumentRoot “/var/www/html”          #存放网页路径<Directory “/var/www”>    AllowOverride None    # Allow open access:    Require all grantedOptions Indexes FollowSymLinks          #开启目录浏览功能 # AllowOverride controls what directives may be placed in .htaccess files.    # It can be “All”, “None”, or any combination of the keywords:    #   Options FileInfo AuthConfig Limit    #    AllowOverride None               #是否启用.htaccess文件    # Controls who can get stuff from this server.    #    Require all granted               #访问控制ErrorLog “logs/error_log”               #错误日志LogLevel warn                         #日志格式(警告)AddDefaultCharset UTF-8               #使用的编码格式IncludeOptional conf.d/.conf             #包含的其他选项/etc/httpd/conf.d/welcome.conf     #自带页面(403错误)![](http://139.199.161.77/linhut/201781_files/Image [1].png)DNS加Apache成功!/etc/httpd/ userdir.conf               #普通用户个人主页must have permissions of 711of 755, and documents contained therein must be world-readable.                 #这文件夹必须要711或755权限,而为可读directory, remove the “UserDir disabled” line above, and uncomment     #需要移除或注释这一条,则开启用户个人主页访问UserDir disabledTo enable requests to /~user/ to serve the user’s public_htmlUserDir public_html      #第一个网页文件<Directory “/home/*/public_html”>     #用户主目录一个网页    AllowOverride FileInfo AuthConfig Limit Indexes    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec    Require method GET POST OPTIONS需要添加apache访问权限:![](http://139.199.161.77/linhut/201781_files/Image [2].png)![](http://139.199.161.77/linhut/201781_files/Image [3].png)报错selinux权限:![](http://139.199.161.77/linhut/201781_files/Image [4].png)查看selinux的安全数据库![](http://139.199.161.77/linhut/201781_files/Image [5].png)修改目的![](http://139.199.161.77/linhut/201781_files/Image [6].png)![](http://139.199.161.77/linhut/201781_files/Image [7].png)想恢复目的![](http://139.199.161.77/linhut/201781_files/Image [8].png)方法二:yum provides seinfo安装包:setools-console-3.3.7-46.el7.x86_64![](http://139.199.161.77/linhut/201781_files/Image [9].png)![](http://139.199.161.77/linhut/201781_files/Image [10].png)方法三:![](http://139.199.161.77/linhut/201781_files/Image [11].png)![](http://139.199.161.77/linhut/201781_files/Image [12].png)找到并开启他方法四:![](http://139.199.161.77/linhut/201781_files/Image [13].png)直接使用它的目的![](http://139.199.161.77/linhut/201781_files/Image [14].png)#总结:这里需要特别注意权限问题,网页目录必须要可读权限,以供apache用户访问;还有selinux开启的时候需要注意他的目的地址,需要对应apache,可使用上面四种方法,chcon修改文件目的做虚拟主机配置:http://www.linhut.cn/manual/mod/core.html#virtualhost![](http://139.199.161.77/linhut/201781_files/Image [15].png)写到主配置文件,也可以写到conf.d里面,不过必须是.conf或拷贝模板![](http://139.199.161.77/linhut/201781_files/Image [16].png)![](http://139.199.161.77/linhut/201781_files/Image [17].png)![](http://139.199.161.77/linhut/201781_files/Image [18].png)firewall-cmd –add-server=http –permanentfirewall-cmd –reload          #防火墙允许通过httpd访问,让外面可以访问elinks     一个简单的网页访问工具[root@dns home]# yum install elinks![](http://139.199.161.77/linhut/201781_files/Image [19].png)![](http://139.199.161.77/linhut/201781_files/Image [20].png)elinks 192.168.0.99/~alex/index.html 视频链接: 链接: http://pan.baidu.com/s/1eRLqppS 密码: grv3