Failed to open stream: Permission denied. composer self-update [fixed]
It is not hard for developers who are using other than shared server to update composer. You can access bin folder and can managed. But for developers who are using shared server, it is not possible to access bin folder. So, today, I have an alternative solution for this.
First of all, we will need to download composer which is completely possible in shared server. To download composer follow these commands on your server. I assume, at least you have shell access to your server.
curl -sS https://getcomposer.org/installer | php
Above commands means, first you are access root directory and downloading composer file there.
Now you will be able to access composer by this command.
Let’s assume you have
/public_html in root directory. Follow following steps to execute composer update command.
In above commands, first, it will direct you to public_html folder and in your website, you will run composer update with ~/composer.phar.
In future, whenever you would like to update composer to latest version, instead of composer self-update, I guess you have already guessed what you need to run. But to complete this blog, here is what you need to do.
If you type alias smcomposer=”~/composer.phar”, it will only for current session. Once you logout and try to use smcomposer, it wont work. To make it work do as following:
- Type nano ~/.bashrc and press
- Paste smcomposer=”~/composer.phar” and press
- Restart ssh and you are good to go.
- Now you can use smcomposer update instead of ~/composer.phar update all the time.
And that’s all. I hope this blog was helpful for those who are using shared server. I mostly use shared server to test how my sites are working. In shared, you will get limited resources and if you are performing your site best in shared, you will get awesome ? website in other best servers out there.
Don’t forget to share ?.