Ameer Hamza
Ameer Hamza

Reputation: 53

How do you update php version to 7 on siteground server?

I have a system build with Laravel 5.5 and it needs PHP version 7. I have deployed the project to site ground server, updated PHP version using PHP version but when I ran php -v command via putty it is showing me PHP version 5. I don't know what going on. I shall be thankful if someone tell me that what is the proper way of updating PHP version? I have also tried AddHandler application/x-httpd-php70s .php in my .htaccess files but got nothing fruitful

Upvotes: 0

Views: 3118

Answers (3)

Luca Pisoni
Luca Pisoni

Reputation: 465

Update 2023

Thanks to this article, i found a solution to my problem. I need php 8.2 on my siteground web hosting and the previous solution opened my eyes but composer did not recognize the new version of php.

You should edit the file ~/.bashrc and add this line:

alias composer="/usr/local/php82/bin/php-cli /usr/local/bin/composer.phar"

Then, reaload the bash interpreter:

~$ source .bashrc

Done. Now composer can install.

Upvotes: 0

Hussnain sheikh
Hussnain sheikh

Reputation: 341

You can change the PHP CLI version through SSH. After connecting through SSH type cd ~ and then find .bash_profile file. Open the .bash_profile file with nano or vi which you would like to use and enter this line:

alias php=/usr/local/php72/bin/php-cli

and save the file. After that run command:

source .bash_profile

And your PHP CLI version has been changed. To confirm the PHP version type php -v and it will show you the version which you just changed.

P.S: In my case, I want to change the PHP CLI version to PHP 7.2 so I use php72 in alias php=/usr/local/php72/bin/php-cli. You can change it to any other version which you need.

Upvotes: 10

Wolen
Wolen

Reputation: 904

So there's no problem if you see PHP5 using command line and PHP7 using php file with phpinfo();. Your hosting provider allows you to choose from several PHP version. You can select PHP7 e.g. using .htaccess but it doesn't have to change PHP CLI version. So when you set PHP7 in .htaccess file it serves your website using PHP7, but CLI is still v5.

By the way, this type of question should be asked on superuser I think.

Upvotes: 1

Related Questions