Ubuntu: www directory is not there when I open var


I am using Ubuntu 14.04. All the directories present in var are listed below:

backups  crash  local  log   metrics  run    tmp  cache    lib    lock   mail  opt      spool  

Why is the www directory missing, and how can I make this right?


The FHS defines the directories and /var/www/ is not a default directory. From the link:


The following directories, or symbolic links to directories, are required in /var.

Directory   Description  cache   Application cache data  lib     Variable state information  local   Variable data for /usr/local  lock    Lock files  log     Log files and directories  opt     Variable data for /opt  run     Data relevant to running processes  spool   Application spool data  tmp     Temporary files preserved between system reboots  

Several directories are `reserved' in the sense that they must not be used arbitrarily by some new application, since they would conflict with historical and/or local practice. They are:

    /var/backups      /var/cron      /var/msgs      /var/preserve  

Apache uses /var/www/html/ and creates it on installation, if it does not exists. Other webservers probably have other locations. Nginx since Ubuntu 15.10 uses this directory as well, but you can also configure it in any Nginx version to use a different directory with the root directive in a site config file (but beware the pitfalls that can happen with this).

If you expect a /var/www/ I would assume you need to install apache (or a lamp-server package).

Otherwise ...

sudo mkdir /var/www/  sudo chmod 755 /var/www  sudo chown root:root /var/www  

to create it as apache would create it.


The /var/www folder does not have to be there by default, as shown by my install:

php :: /var » k  total 72  drwxr-xr-x  2 root  root 4096 12 Jul   06:25   backups  drwxr-xr-x  9 root  root 4096 22 Jun   00:01   cache  drwxr-xr-x 36 root  root 4096 29 Jun   22:56   lib  drwxrwsr-x  2 root staff 4096 14 Mar   10:46   local  lrwxrwxrwx  1 root  root    9 12 Jun   02:32   lock -> /run/lock  drwxr-xr-x 10 root  root 4096 12 Jul   06:25   log  drwxrwsr-x  2 root  mail 4096 21 Jun   23:56   mail  drwxr-xr-x  2 root  root 4096 12 Jun   02:32   opt  lrwxrwxrwx  1 root  root    4 12 Jun   02:32   run -> /run  drwxr-xr-x  6 root  root 4096 12 Jun   03:06   spool  drwxrwxrwt  2 root  root 4096 12 Jun   02:38   tmp  

Simply create the folder with sudo mkdir /var/www.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »