Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

angelorigo's avatar

Mkdir permission denied

Hi, I am using Ubuntu 23.1, at the terminal with my normal user, when i run Laravel new aplication, it gives me error message : In ProjectInstaller.php line 69: mkdir(): Permission denied

How do i solve this? what permission must be given to run the laravel binary ?

0 likes
2 replies
LaryAI's avatar
Level 58

To solve the "mkdir(): Permission denied" error when creating a new Laravel application on Ubuntu, you need to ensure that your user has the necessary permissions to create directories in the target location. Here are the steps you can follow to resolve this issue:

  1. Check the Directory Permissions: Ensure that your user has write permissions to the directory where you are trying to create the new Laravel application.

    ls -ld /path/to/parent/directory
    

    Replace /path/to/parent/directory with the actual path where you want to create the Laravel project. The output will show the permissions of the directory.

  2. Change Directory Permissions: If the directory does not have the correct permissions, you can change them using the chmod command. For example, to give write permissions to the user:

    sudo chmod u+w /path/to/parent/directory
    
  3. Change Directory Ownership: If the directory is owned by another user, you can change the ownership to your current user using the chown command. Replace yourusername with your actual username:

    sudo chown yourusername:yourusername /path/to/parent/directory
    
  4. Run Laravel Installer with Sudo (Not Recommended): As a last resort, you can run the Laravel installer with sudo, but this is generally not recommended because it can lead to permission issues later on.

    sudo laravel new application-name
    
  5. Create the Project in a Directory with Proper Permissions: Alternatively, you can create the Laravel project in a directory where you already have the necessary permissions, such as your home directory.

    cd ~
    laravel new application-name
    

Here is a summary of the commands you might need:

# Check directory permissions
ls -ld /path/to/parent/directory

# Change directory permissions
sudo chmod u+w /path/to/parent/directory

# Change directory ownership
sudo chown yourusername:yourusername /path/to/parent/directory

# Create Laravel project in a directory with proper permissions
cd ~
laravel new application-name

By following these steps, you should be able to resolve the "mkdir(): Permission denied" error and successfully create a new Laravel application.

angelorigo's avatar

After running chown it works, thank you.

Please or to participate in this conversation.