Here we talk about the File Permission for your own server or private hosting set up. You may not login or switch to the web server user in this type of setup. The web server is not the file system user and is different user; therefore, there are at least two users: File system user (Your account) and Web Server User (www-data in Ubuntu).
In this topic, the following steps will explain you how to create a new Magento file system owner and put that user in the web servers group in Ubuntu server.
Step 1: Form a Magento File System owner
Step 2: Get the Web Server user’s group
Step 3: Place the owner of the Magento file system on a Web server group
Step 4: Place the ownership and permission for Magento
Step 1
To form a user, type the following command as a user with root rights:
Adduser <username>
To provide the user a password, type the following command as a user with root rights:
Password <username>
Step 2
–ps aux | grep apache to get the apache user
-groups <apache user> to get the group
In general, the user name and the group name are both www-data
Step 3:
usermod -g www-data <username>
To confirm your Magento user is a member of the web server group, enter the following command:
groups <user name>
Step 4:
You should set ownership and permissions before you install the Magento
- Log in to your Magento server and switch to the Magento file system owner.
- Type the following commands
- cd <your Magento install dir>
- Get var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
- Get var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;
- chown -R :<web server group> .
- chmod u+x bin/magento
You may type the following assume Magento is installed in/var/www/html/magento2 and the web server group name is apache to alternately type all commands on one line:
cd /var/www/html/magento2 && find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \; && find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \; && chown -R :apache . && chmod u+x bin/magento
You can order the directory as root owners because the event file system permissions are set incorrectly and the owner of the Magento file system cannot be changed:
cd /var/www/html/magento2 && sudo find var 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 :apache . && sudo chmod u+x bin/magento
Leave a Reply