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
  • 110,292
  • 102
  • 269
  • 299
user21839
  • 81
  • 2
  • 2
  • 7

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
  • 193,181
  • 53
  • 473
  • 722
  • I have a follow up question. Now after running $ sudo mkdir -p /var/www/magento-dev.local/public and $ sudo chown -R www-data:www-data /var/www/magento-dev.local I try to run the command $ sudo a2ensite magento-dev.local and I get the following error "ERROR: Site magento-dev.local does not exist!" As the question indicates the file does exist!!! – user21839 Sep 29 '14 at 19:48
  • @user21839 in apache 2.4, site configuration files are supposed to have a `.conf` extension. – muru Sep 29 '14 at 19:49
  • so the file created in /etc/apache2/sites-available directory should be called magento-dev.local.conf and the command should be sudo a2ensite magento-dev.local.conf? – user21839 Sep 29 '14 at 19:53
  • @user21839 yep. You might also need to correct some options in the configuration, but that's a whole new question. – muru Sep 29 '14 at 19:55