Skip to main content

I need to set the default php-version of a subscription to php7.3.  The current server php version is PHP 7.1.33 (cli) (built: Oct 25 2019 11:33:58) ( NTS ).

Using a shell program (I used Terminal) from the home directory I ran:

export PATH=/opt/plesk/php/7.3/bin:$PATH;

centos 6 use

service httpd restart

centos 7 use

sudo systemctl restart httpd.service

However, through shell when I ran php -v the version remained at 7.1.33.

Incase the restart wasn't enough I rebooted the server using 

sudo reboot

Looking through the documentation on Plesk support, I came across this chat command "php" version for SSH

After switching the subscription user I followed the steps 

echo "alias php='/opt/plesk/php/7.3/bin/php'" >> ~/.bashrc

including Jari's reference that rather than ~/bashrc us ~/bash_profile.  However, even after a restart and reboot the PHP version remained at 7.1.33.  Don't get me wrong, whilst in the subscription the PHP version was correct being PHP 7.3.20 (cli) (built: Jul 24 2020 13:12:45) ( NTS ).

I went back the relevant home directory and ran 

export PATH=/opt/plesk/php/7.3/bin:$PATH;

sudo reboot

When I checked the PHP version - 7.3.20.

So, to get the correct PHP version running through shell I did:

  • At root directory
    • echo "alias php='/opt/plesk/php/7.3/bin/php'" >> ~/.bashrc
  • At home directory
    • export PATH=/opt/plesk/php/7.3/bin:$PATH;
  • sudo reboot

If the above comments haven't solve this issue, refer to How to run Composer with Plesk PHP.  In this article they recommend /opt/plesk/php/X.X/bin/php /usr/lib64/plesk-9.0/composer.phar [options] [arguments].  As we are attempting to get php 7.3 as the recognised base, X.X becomes 7.3.  Then replace the options and arguments with what you are attempting to do.  For us, global require laravel/installer:3

/opt/plesk/php/7.3/bin/php /usr/lib64/plesk-9.0/composer.phar [options] [arguments]

 

Other Apache commands

Apache documentation recommends using a control script to pass commands to the httpd process.  Restarting Apache in this manner, you would enter the following:

sudo apachectl –k restart

Terminate all child processes and itself, run the following command:

apachectl –k stop

Exit child processes after they finish a task and then launch new instances. The service will reload configuration files as well:

apachectl –k graceful

Use -k restart to force child processes to exit. The parent process stays running, and reloads configuration files:

apachectl –k restart

Use -k graceful-stop to force parent process to stop child processes as they complete their tasks. Once all child processes are stopped, the parent process exits:

apachectl –k graceful–stop

 

Other commands to use with Systemctl

To start the Apache service:

sudo systemctl start httpd.service

Stop the Apache service with:

sudo systemctl stop httpd.service

Force Apache to refresh the configuration files:

sudo systemctl reload httpd.service

Set Apache to run when the system boots:

sudo systemctl enable httpd.service

Prevent Apache from loading when the system boots:

sudo systemctl disable httpd.service

Related articles

Andrew Fletcher18 Mar 2024
Resolving CVE-2022-48624 less issue
To resolve the CVE-2022-48624 vulnerability on Ubuntu using Nginx, it's crucial to understand that the issue lies within the "less" package, not Nginx itself. The vulnerability affects "less" before version 606, where close_altfile in filename.c in less omits shell_quote calls for LESSCLOSE,...