Some of this may be due to the OS your server is running. I recently did a migration to a new hosting environment running Ubuntu. Adding this alias alias composer="/path/to/your/composer"
to .bashrc or .bash_aliases didn't work at first because of two reasons:
The server was running csh, not bash, by default. To check if this is an issue in your case, run echo $0
. If the what is returned is -csh
you will want to change it to bash, since some processes run by Composer will fail using csh/tcsh.
To change it, first check if bash is available on your server by running cat /etc/shells
. If, in the list returned, you see bin/bash
, you can change the default to bash by running chsh -s /bin/csh
.
Now, at this point, you should be able to run Composer, but normally, on Ubuntu, you will have to load the script at every session by sourcing your Bash scripts by running source ~/.bashrc
or source ~/.bash_profile
. This is because, in most cases, Ubuntu won't load your Bash script, since it loads .profile
as the default script.
To load your Bash scripts when you open a session, try adding this to your .profile (this is if your Bash script is .bashrc—modify accordingly if .bash_profile or other):
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
To test, close your session and reload. If it's working properly, running composer -v
or which composer
should behave as expected.