47

我阅读了 William Shotts的 The Linux Command Line,其中有一些 Linux 文件(系统目录)的描述:

目录内容/var不会改变。这棵树是存储可能更改的数据的地方。各种数据库、假脱机文件、用户邮件等都位于此处。

我想知道:如果/var目录内容不应该改变,为什么安装后会有一个www目录?/var/wwwapache-php

/var/www目录是我们必须编辑、创建或删除文件的地方。这是一个本地主机公共目录。

为什么他说/var目录内容不会改变?

4

4 回答 4

85

这种描述/var是自相矛盾的。/var包含易于更改的内容,例如网站、临时文件 ( /var/tmp) 和数据库。该名称是“变量”的缩写。

于 2013-08-29T15:20:12.173 回答
33

男子汉

   /var   This directory contains files which may change in size, such as spool and log files.

   /var/account
          Process accounting logs (optional).

   /var/adm
          This directory is superseded by /var/log and should be a symbolic link to /var/log.

   /var/backups
          Reserved for historical reasons.

   /var/cache
          Data cached for programs.

   /var/cache/fonts
          Locally-generated fonts (optional).

   /var/cache/man
          Locally-formatted man pages (optional).

   /var/cache/www
          WWW proxy or cache data (optional).

   /var/cache/<package>
          Package specific cache data (optional).

   /var/catman/cat[1-9] or /var/cache/man/cat[1-9]
          These directories contain preformatted manual pages according to their man page section.  (The use of preformatted manual pages is deprecated.)

   /var/crash
          System crash dumps (optional).

   /var/cron
          Reserved for historical reasons.

   /var/games
          Variable game data (optional).

   /var/lib
          Variable state information for programs.

   /var/lib/hwclock
          State directory for hwclock (optional).

   /var/lib/misc
          Miscellaneous state data.

   /var/lib/xdm
          X display manager variable data (optional).

   /var/lib/<editor>
          Editor backup files and state (optional).

   /var/lib/<name>
          These directories must be used for all distribution packaging support.

   /var/lib/<package>
          State data for packages and subsystems (optional).

   /var/lib/<pkgtool>
          Packaging support files (optional).

   /var/local
          Variable data for /usr/local.

   /var/lock
          Lock files are placed in this directory.  The naming convention for device lock files is LCK..<device> where <device> is the device's name in the filesystem.  The format used is that  of  HDU
          UUCP lock files, that is, lock files contain a PID as a 10-byte ASCII decimal number, followed by a newline character.

   /var/log
          Miscellaneous log files.

   /var/opt
          Variable data for /opt.

   /var/mail
          Users' mailboxes.  Replaces /var/spool/mail.

   /var/msgs
          Reserved for historical reasons.

   /var/preserve
          Reserved for historical reasons.

   /var/run
          Run-time variable files, like files holding process identifiers (PIDs) and logged user information (utmp).  Files in this directory are usually cleared when the system boots.

   /var/spool
          Spooled (or queued) files for various programs.

    /var/spool
          Spooled (or queued) files for various programs.

   /var/spool/at
          Spooled jobs for at(1).

   /var/spool/cron
          Spooled jobs for cron(8).

   /var/spool/lpd
          Spooled files for printing (optional).

   /var/spool/lpd/printer
          Spools for a specific printer (optional).

   /var/spool/mail
          Replaced by /var/mail.

   /var/spool/mqueue
          Queued outgoing mail (optional).

   /var/spool/news
          Spool directory for news (optional).

   /var/spool/rwho
          Spooled files for rwhod(8) (optional).

   /var/spool/smail
          Spooled files for the smail(1) mail delivery program.

   /var/spool/uucp
          Spooled files for uucp(1) (optional).

   /var/tmp
          Like /tmp, this directory holds temporary files stored for an unspecified duration.

   /var/yp
          Database files for NIS, formerly known as the Sun Yellow Pages (YP).
于 2018-05-08T06:44:34.947 回答
16

Linux File-system Hierarchy StandardLinux Standard Base给出了预期可用的各种文件(包括目录)的定义。/ var 层次结构

包含可变数据文件。这包括假脱机目录和文件、管理和日志数据以及临时和临时文件。

有趣/var/www/的是没有在这样的规范规范中定义。

于 2013-08-29T15:29:44.437 回答
-16

我会说 /var 中的内容不会经常更改。根据我的经验,它主要用于存储数据库文件、缓存文件,当然还有 /var/www 目录。这些对象确实会发生变化,但例如,网站不会每秒都在变化。

于 2013-08-29T15:34:26.477 回答