cancel
Showing results for 
Search instead for 
Did you mean: 

Is this the correct composer settings when using mod_fcgi, using post-install-cmd and post-update-cm

Is this the correct composer settings when using mod_fcgi, using post-install-cmd and post-update-cm

Every time I update Magento using "composer update" or even installing magento with "composer install" all my .htaccess file modifications needed for mod_fcgi need to be fixed. So I wrote a simple script to update all .htaccess files to work in a mod_fcgi environment using post-install-cmd and post-update-cmd inside composer.json. Please let me know if there's a better way to do this or if this looks good.

 

I manually edited composer.json from this...

 

    "scripts": {
        "post-install-cmd": [
            "chmod ug+x bin/magento"
        ]
    },

to this...

 

 

    "scripts": {
        "post-install-cmd": [
            "chmod ug+x bin/magento",
            "./composer-post.sh"
        ],
        "post-update-cmd": "./composer-post.sh"
    },

And I made a file called composer-post.sh with executable rights in the root directory of Magento 2 with this content...

 

 

#!/bin/bash
# Make things work in fcgi enviroment
printf "Replacing '+FollowSymLinks' with '+SymLinksIfOwnerMatch' in all .htaccess files..."
find . -type f -name '.htaccess' -exec sed -i 's/\+FollowSymLinks/\+SymLinksIfOwnerMatch/g' {} +
printf "  DONE\n"
printf "Replacing 'Options All -Indexes' with 'Options -Indexes' in all .htaccess files..."
find . -type f -name '.htaccess' -exec sed -i 's/Options All \-Indexes/Options \-Indexes/g' {} +
printf "  DONE\n"

Does anyone have suggestion on how to improve this or is this the right method?