I run multiple versions of PHP on my Linux server. I've added an alias in my bashrc to point the php
command to a specific version alias php='/usr/bin/php7.3'
.
This works as expected when I execute a PHP script actually using the php command eg php myscript.php
However, if I make myscript.php
an executable and put the shebang #!/usr/bin/env php
at the top, it executes the script with the default version of PHP, and does not use the alias defined in my bashrc.
I know I can change the shebang to #!/usr/bin/env /usr/bin/php7.3
, but I need this globally, rather than file by file.
Is it possible to set an alias for the php
command which is respected in the shebang?