The Power of Feedback: How Regular Check-Ins Can Transform Employee Performance and Engagement
Read More
Updating PHP and Composer versions on Hostinger using SSH CLI can be challenging, especially without sudo
access. This guide simplifies the process and ensures you can work seamlessly within the limitations of shared hosting environments.
When using Hostinger's shared hosting, you may encounter restrictions that prevent direct updates to software like PHP and Composer. By leveraging SSH and local configurations, you can still update these tools effectively. This guide will walk you through updating PHP and Composer step by step.
Hostinger provides multiple PHP versions that can be selected through custom configuration. Follow these steps to update PHP:
Run the following command to check the current PHP version:
php --version
To use a newer version of PHP (e.g., PHP 8.2):
Open your .bashrc
file to set a new alias:
nano ~/.bashrc
Add or update the alias for PHP:
alias php=/opt/alt/php82/usr/bin/php
Save the file and reload it:
source ~/.bashrc
Verify the updated PHP version:
php --version
If the output shows PHP 8.2 (or your desired version), the update was successful.
Composer is an essential tool for managing dependencies in PHP projects. Follow these steps to update Composer to the latest version:
Run the following command to download the latest Composer installer:
curl -sS https://getcomposer.org/installer | php -- --2
This command downloads the composer.phar
file to your current directory.
Create a bin
directory in your home folder if it doesn’t exist:
mkdir -p ~/bin
Move composer.phar
to the bin
directory:
mv composer.phar ~/bin/composer
Open your .bashrc
file:
nano ~/.bashrc
Add the following line to include ~/bin
in your PATH:
export PATH="$HOME/bin:$PATH"
Save the file and reload the shell configuration:
source ~/.bashrc
Verify the Composer version:
composer --version
If the output shows the latest version, Composer has been successfully updated.
If PHP does not update:
Ensure the alias points to the correct path (e.g., /opt/alt/php82/usr/bin/php
).
Check the active PHP binary using:
which php
If Composer fails to execute:
Verify the composer
file has execute permissions:
chmod +x ~/bin/composer
Ensure ~/bin
is in your PATH.
By following this guide, you can seamlessly update PHP and Composer versions on Hostinger using SSH CLI without needing sudo
access. This approach empowers developers to maintain an up-to-date development environment even in shared hosting scenarios.
Yes, you can use Hostinger’s control panel to switch PHP versions without SSH access.
Composer updates improve performance, add features, and ensure compatibility with modern PHP versions and packages.
curl
installed?You can use wget
as an alternative to download the Composer installer:
wget -O composer-setup.php https://getcomposer.org/installer
php composer-setup.php --2
Keep your tools updated for better performance and compatibility! If you face any issues, let us know in the comments below.
Recent posts form our Blog
0 Comments
Like 0