2

I'm trying to install Magento on an Ubuntu 14.04 server. I created a file called magento-dev.local in the /etc/apache2/sites-available/ directory. that has the following contents:

<VirtualHost *:80>
 # ServerName (domain) and admin email
 ServerAdmin webmaster@magento-dev.local
 ServerName magento-dev.local

 # Folder of this site. This is required.
 DocumentRoot /var/www/magento-dev.local/public 

 # Log file locations
 LogLevel warn
 ErrorLog /var/log/apache2/magento-dev.error.log
 CustomLog /var/log/apache2/magento-dev.access.log combined
</VirtualHost>

I get the following error when I try and run this command:

$ sudo mkdir /var/www/magento-dev.local/public
mkdir: cannot create directory '/var/www/magento-dev.local/public': No such file or directory

How do I fix this problem?

karel
  • 122,292
  • 133
  • 301
  • 332

1 Answers1

3

mkdir will fail if any directory in the given path (except the last) doesn't exist. Use the -p option to tell it to make such directories automatically:

sudo mkdir -p /var/www/magento-dev.local/public

Be warned that this can create problems if you made a typo:

sudo mkdir -p /var/www/magento-deva.local/public

This will create a magento-deva.local directory and a public directory in it. Always double check your paths if you use -p.

From man mkdir:

-p, --parents
      no error if existing, make parent directories as needed
muru
  • 207,228