apache
     80端口,是一个web服务,使用HTTP协议,超文本协议。
     HTTPS:43端口
他的解析过程和DNS服务类似。
1.安装apache
[root@dns named]# yum install httpd* -y
httpd-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:80
Listen 80                    #使用端口
Include conf.modules.d/*.conf     #加载模块
User apache                  #Apache的所属用户
Group apache                 #Apache的所属组
ServerAdmin root@localhost          #管理员邮件
#ServerName www.example.com:80          #网页名(必须是可解析)
<Directory />                          #目录容器
    AllowOverride none
    Require all denied
</Directory>
DocumentRoot "/var/www/html"          #存放网页路径
<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>
Options 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错误)
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 disabled
To enable requests to /~user/ to serve the user's public_html
UserDir public_html      #第一个网页文件
<Directory "/home/*/public_html">     #用户主目录一个网页
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Require method GET POST OPTIONS
</Directory>
需要添加apache访问权限:
报错selinux权限:
查看selinux的安全数据库
修改目的
想恢复目的
方法二
yum provides seinfo
安装包:setools-console-3.3.7-46.el7.x86_64
方法三
找到并开启他
方法四
直接使用它的目的
#总结:这里需要特别注意权限问题,网页目录必须要可读权限,以供apache用户访问;还有selinux开启的时候需要注意他的目的地址,需要对应apache,可使用上面四种方法,chcon修改文件目的
做虚拟主机配置:
写到主配置文件,也可以写到conf.d里面,不过必须是.conf
或拷贝模板
firewall-cmd --add-server=http --permanent
firewall-cmd --reload          #防火墙允许通过httpd访问,让外面可以访问
elinks
     一个简单的网页访问工具
[root@dns home]# yum install elinks
elinks 192.168.0.99/~alex/index.html
视频链接: 链接: http://pan.baidu.com/s/1eRLqppS 密码: grv3