在服务搭建前,还要了解一下httpd的日志。

日志有助有工作人员,查看服务器出错状况,更能统计数据分析网页运行情况。

PV和UV两大分析

PV  Page View 页面访问量

UV  User View 用户访问量

1)指定错误日志的名称及级别

错误日志的路径:/var/log/httpd/error_log

错误级别: debug, info, notice, warn, error, crit

访问日志: /var/log/httpd/access_log

[root@wei httpd]# head -n 1 /var/log/httpd/access_log


(2)定义访问日志的格式

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

192.168.196.1 - - [07/Mar/2019:05:33:39 +0800] "GET / HTTP/1.1" 200 1766 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36"

%h 远端主机

       %l 远端登录名(由identd而来,如果支持的话),除非IdentityCheck设为"On",否则将得到一个"-"。

       %u 远程用户名(根据验证信息而来;如果返回status(%s)为401,可能是假的)

       %t 时间,用普通日志时间格式(标准英语格式)

       %r 请求的第一行

       %>s:HTTP状态码

       %b 以CLF格式显示的除HTTP头以外传送的字节数,也就是当没有字节传送时显示’-'而不是0。

       %{Referer}i:记录超链接地址

       %{User-Agent}i:记录客户端的浏览器类型

(3)指定访问日志的名称及格式

CustomLog "logs/access_log" combined

虚拟主机 VirtualHost

作用:在一台物理服务器上运行多个网站

    

    类型:

         基于域名的虚拟主机(常用)

         基于IP地址的虚拟主机

         基于端口的虚拟主机

         

配置虚拟主机

<VirtualHost 10.1.2.3:80>
  ServerAdmin webmaster@host.example.com
  DocumentRoot /www/docs/host.example.com
  ServerName host.example.com
  ErrorLog logs/host.example.com-error_log
  TransferLog logs/host.example.com-access_log
</VirtualHost>

示例:基于主机名的虚拟主机

www.a.org    网页目录:/var/www/html/a.org   日志:/var/log/httpd/a.org

www.a.org

(1)准备目录

[root@wei ~]# mkdir /var/www/html/a.org
[root@wei ~]# vim /var/www/html/a.org/index.html
[root@wei ~]# mkdir /var/log/httpd/a.org

(2)编写配置文件

[root@wei ~]# vim /etc/httpd/conf.d/a.org.conf
<VirtualHost 192.168.196.132:80>
  DocumentRoot /var/www/html/a.org
  ServerName www.a.org
  ErrorLog /var/log/httpd/a.org/error_log
  CustomLog /var/log/httpd/a.org/access_log combined </VirtualHost>

(3)检测配置文件语法

[root@wei ~]# httpd -t

(4)重启服务

[root@wei ~]# systemctl restart httpd

Linux的httpd服务搭建的更多相关文章

  1. Linux下httpd服务与Apache服务的查看和启动

    转:http://jingyan.baidu.com/article/63f236282d43170209ab3d43.html 这里简要介绍Linux环境中Apache也就是httpd服务的启动,查 ...

  2. linux之FTP服务搭建 ( ftp文件传输协议 VSFTPd虚拟用户)

    FTP服务搭建 配置实验之前关闭防火墙 iptables -F iptables -X iptables -Z systemctl stop firewalld setenforce 0 1.ftp简 ...

  3. linux启动httpd服务出现 Could not reliably determine the server`s fully qualified domain name.

    安装好apache启动httpd服务时,出现httpd: Could not reliably determine the server's fully qualified domain name,  ...

  4. Linux 之dhcp服务搭建

    DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议 dhcp服务器端监控端口67 涉及的配置文件:/etc/dhcp/dhcpd ...

  5. linux 下httpd服务开机启动

    分类: 网站搭建2011-01-07 05:52 1164人阅读 评论(0) 收藏 举报 linuxapache 我的apache安装目录在 /usr/local/apache 有2种方法可以设置开机 ...

  6. linux下FTP服务搭建(1)

    1.FTP介绍: FTP (File Transfer Protocol,文件传输协议)主要用来文件传输,尤其适用于大文件传输,提供上传下载功能 FTP官方网站:https://filezilla-p ...

  7. Linux的httpd服务介绍和部署

    软件介绍 客户端代理软件     IE,firefox,chroome,opera      服务器端软件      httpd,Nginx,Tengine,ISS,Lighthttp       应 ...

  8. Linux之NFS服务搭建及autofs服务搭建

    NFS 网络文件系统,英文Network File System(NFS),是由SUN公司研制的UNIX表示层协议(presentation layer protocol),能使使用者访问网络上别处的 ...

  9. linux下svn服务搭建

    安装svn需要依赖apr和apr-util这两个软件,所以先安装这两个软件 下载安装APR wget http://apache.fayea.com//apr/apr-1.5.2.tar.gz .ta ...

随机推荐

  1. 【oracle】ORA-12638 : 身份证明检索失败

    sqlnet.ora 1.删了 2.#注释了 背后缘由:待写

  2. c# 多线程多个参数

    for (int i = 0; i <count; i++) //根据选择的串口号数量创建对应数量的线程 { thread = new Thread(new ParameterizedThrea ...

  3. JOI2013-2019题解

    JOI2013-2019题解 Link

  4. [LeetCode] 382. Linked List Random Node 链表随机节点

    Given a singly linked list, return a random node's value from the linked list. Each node must have t ...

  5. [LeetCode] 139. Word Break 拆分词句

    Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine ...

  6. [LeetCode] 2. Add Two Numbers 两个数字相加

    You are given two non-empty linked lists representing two non-negative integers. The digits are stor ...

  7. swagger Unable to render this definition

    Unable to render this definition The provided definition does not specify a valid version field. Ple ...

  8. 第26课 std::async异步任务

    一. std::async函数模板 (一)std::async和std::thread的区别 1. 两者最明显的区别在于async采用默认启动策略时并不一定创建新的线程.如果系统资源紧张,那么std: ...

  9. 5行代码带你实现一个js的打字效果

    (转载)原文链接:https://juejin.im/post/5ddf55835188257313541581 前言 有次看电影

  10. HandlerInterceptorAdapter

    handler,是指controller的@Controller注解下的整个方法名