> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.weltpixel.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to set Magento 2 permissions and avoid installation errors

If you encounter installation issues or read/write errors in Magento 2, you may need to correct **file permissions and ownership**. Below are recommended setups for **basic** and **advanced** permissions.

---

## 1. Basic Permissions Setup

We recommend the following permissions for Magento:

- **Directories:** `711`  
- **PHP files:** `600`  
- **All other files:** `644`  

Run these commands from your Magento root:

    find . -type d -exec chmod 0711 {} +
    find . -type f -exec chmod 0644 {} +
    find . -type f -name "*.php" -exec chmod 600 {} +

Set the correct ownership (replace `<owner>:<group>` with your actual user and group):

    chown -R <owner>:<group> .

> Common groups include: `www-data:www-data`, `root:root`, `www-data:magento` — but this depends on your server setup.

Finally, make `bin/magento` executable:

    chmod u+x bin/magento

---

## 2. Advanced Permissions Setup

On private servers, you may log in as one user but run the web server as another. In this case, both users need to be in the **same group** to allow proper file access.

### Step 1 — Find your username

    whoami

### Step 2 — Identify the web server user

    ps aux | grep apache

Usually, it’s `www-data`.

### Step 3 — Find the web server group

    groups www-data

(Replace `www-data` with your web server user if different.)

### Step 4 — Add your user to the web server group

    sudo usermod -a -G www-data <your_username>

### Step 5 — Confirm group membership

    groups <your_username>

Your username should now be listed as a member of multiple groups, including `www-data`.  
Restart your web server to apply changes:

- Ubuntu:

      service apache2 restart

- CentOS:

      service httpd restart

### Step 6 — Set ownership and permissions

Navigate to your Magento installation directory and run:

    cd <your Magento install directory>
    find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
    find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
    sudo chown -R <your_username>:<web server group> .
    chmod u+x bin/magento

You can also run it in one line (assuming group is `www-data`):

    find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + && find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + && chown -R www-data:www-data . && chmod u+x bin/magento

If permissions cannot be set by the Magento user, use **root privileges**:

    sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \; && sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \; && sudo chown -R www-data:www-data . && sudo chmod u+x bin/magento

---

## Notes

- **FTP uploads**: Files copied via FTP may have incorrect permissions or group ownership. Rerun the permission setup after copying.  
- **Group mismatch**: Ensure your user belongs to the same group as Magento files. Otherwise, newly copied files may cause installation errors.  

For more details, see:  
[Bitnami AWS - Installation issues with Magento 2 Theme or Extensions [Solved]](https://support.weltpixel.com/hc/en-us/articles/115006621627-Bitnami-AWS-Installation-issues-with-Magento-2-Theme-or-Extensions-Solved-)