This article covers:
- Magento 2.3 file system owner and permission
- Update to Magento 2.3.4 using Composer
Audiences of this article:
- Magento 2.3 developers
Getting Magento 2.3 file and folder permission right
One of the most confusing areas about Magento 2 development is getting the file system owner and permission right. Due to a lack of workable official recommendations, prior to Magento 2.3, there were thousands of threads floating around the Internet asking for the best way to set up Magento to server. Fortunately, this has become a thing in the past, now Magento 2 has come up with clear instruction of setting up Magento 2 pre-installation file system ownership. Since we only use dedicated VPS for our Magento 2 hosting, our file system user has been added to apache group www-data. This is what we did:
Firstly go to Magento 2 root directory, then use below SSH command:
sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + && sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + && sudo chown -R :apache . && sudo chmod u+x bin/magento
Update Magento 2 with Composer
We assume that you’re using composer to manage your Magento 2 and its modules. Here is a list of SSH commands to update Magento from 2.3.0 to 2.3.4.
Make sure you have backed up your Magento 2 database and file system. Firstly, put Magento 2 in maintenance mode:
bin/magento maintenance:enable
Then get Magento 2 ready for the upgrade, we prefer to use no-update in this step in case of any module conflicts.
composer require magento/product-community-edition 2.3.4 --no-update
After all the requirements are ready, go ahead execute the upgrade. Once it’s completed, update the Magento database and disable Maintenance mode.
composer update bin/magento setup:upgrade bin/magento maintenance:disable
Unlike our previous experience on updating Magento from 2.2.0 to 2.2.3 which caused enormous problems, so bad that we have to recover Magento 2 from a backup disk. This time, since we have the correct file and folder permission. Magento 2 has been successfully updated to 2.3.4. Having said that, in any major Magento 2 updates, it’s always a good practice to backup your database and file system in case the update fails which was a commonplace prior to Magento 2.3.