在服务搭建前,还要了解一下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. C++中int与string的相互转换

    一.int转string 1.c++11标准增加了全局函数std::to_string: string to_string (int val); string to_string (long val) ...

  2. python中使用rsa加密

    前提不多说, 为什么使用RSA加密请自行搜索,直接正为: 一. 生成公钥及私钥, 并保存 二. 使用公钥加密, 私钥解密 后记: 通常使用中, 会先对数据进行bas64加密, 再对加密后的内容使用rs ...

  3. divide two numbers using + opertor

    package testpacknm; import java.util.Scanner; public class testcnm { public static void main(String[ ...

  4. Elasticsearch由浅入深(十一)内核原理

    倒排索引组成结构以及索引不可变原因 对于倒排索引是非常适合用来进行搜索的它的结构:(1)包含这个关键词的document list(2)包含这个关键词的所有document的数量:IDF(invers ...

  5. Vue.js项目中使用iconfont冲突问题解决

    在开发前端项目中,字体图标变得越来越常用.一方面因为它比图片使用起来方便,可以像字体一样修改大小和颜色:另一方面是因为它可以减少请求数量,优化前端性能. iconfont的使用方法很简单,主要由三种引 ...

  6. Navicat Keygen - for Windows

    如何使用这个注册机 从这里下载最新的release. 使用navicat-patcher.exe替换掉navicat.exe和libcc.dll里的Navicat激活公钥. navicat-patch ...

  7. 【RS】A review on deep learning for recommender systems: challenges and remedies- 推荐系统深度学习研究综述:挑战和补救措施

    [论文标题]A review on deep learning for recommender systems: challenges and remedies  (Artificial Intell ...

  8. 调试MATLAB代码

    1.在子函数设置的断点,在运行时,不起作用: 因为在主函数开始时,使用了clear all,在运行时,会把断点给删除.

  9. MySQL8的密码策略

    解释: 由于valiadte_password策略.密码强度需要非常高,所以有时候密码都无法成功修改.了解完下面变量就能解决了. validate_password.policy:密码策略,检查用户的 ...

  10. Ansible15:文件管理模块及Jinja2过滤器

    目录 常用文件管理模块 1. file 2. synchronize 3. copy 4. fetch 5. lineinfile 6. stat 7. blockinfile Jinja2模板管理 ...