3.2.1 Linux系统中的配置文件

1.配置文件

/etc/httpd:服务目录
/etc/httpd/conf/httpd.conf:主配置文件
/var/www/html:网站数据目录
/var/log/httpd/access_log:访问日志
/var/log/httpd/error_log:错误日志

2.主配置文件参数及含义

ServerRoot:服务目录
ServerAdmin:管理员邮箱
User:运行服务的用户
Group:运行服务的用户组
ServerName:网站服务器的域名
DocumentRoot:网站数据目录
Listen:监听的IP 地址与端口号
DirectoryIndex:默认的索引页页面
ErrorLog:错误日志文件
CustomLog:访问日志文件
Timeout:网页超时时间,默认为 300 秒
在httpd服务程序的主配置文件中,存在3种类型的信息:注释行信息、全局配置、区域配置
[root@dsrw ~]# vim /etc/httpd/conf/httpd.conf
ServerRoot "/etc/httpd" 全局配置
#          注释行信息
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

<Directory />  区域配置
    AllowOverride none
    Require all denied
</Directory>

......

3.创建新的网页测试

[root@dsrw ~]# echo "Welcome To dsrw.Com" > /var/www/html/index.html
[root@dsrw ~]# firefox
图片[1]-3.2.1 Linux系统中的配置文件-大赛人网
图3-2 测试

4.修改网站保存目录

建立网站数据的保存目录,并创建首页文件
[root@dsrw ~]# mkdir /home/www
[root@dsrw ~]# echo "Welcome to dsrw.com!" >/home/www/index.html
[root@dsrw ~]# vim /etc/httpd/conf/httpd.conf
DocumentRoot "/home/www"
<Directory "/home/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>
[root@dsrw ~]# systemctl restart httpd
[root@dsrw ~]# firefox
图片[2]-3.2.1 Linux系统中的配置文件-大赛人网
图3-3页面提示权限不足
© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称

    请登录后查看评论内容