Header Ads

How to change user/groups, permission with Magento 2, Nginx, PHP-fpm

How to change user/groups, permission with Magento 2, Nginx, PHP-fpm


How to change user/group, permission with magento 2, nginx, php-fpm



Make sure the local workstation installed Nginx, php7.2-fpm on ubuntu.


1, Get a current user name



echo ${USER}

How to change user/group, permission with magento 2, nginx, php-fpm


2, Change user/group run with current user:


sudo vim /etc/php/7.2/fpm/pool.d/www.conf

Find to the line and change to the current user:

user = <current-user>
group = <current-user>

listen.owner = <current-user>
listen.group = <current-user>

EX: 

user = dylan
group = dylan

listen.owner = dylan
listen.group = dylan

How to change user/group, permission with magento 2, nginx, php-fpm

Save file.

3, Add user to group



sudo adduser www-data <current-user>

EX: sudo adduser www-data dylan

4, Change all permission, own in workspace Magento 2


Go to Magento 2 folder and run the command:

sudo chown -R ${USER}:${USER} .

sudo find -type d -exec chmod 755 {} \;
sudo find -type f -exec chmod 755 {} \;

How to change user/group, permission with magento 2, nginx, php-fpm

5, Restart php-fpm, nginx

sudo systemctl restart php7.2-fpm

sudo systemctl restart nginx

That's all.

No comments