SOLVED Specific PHP-CLI version for account

gizmo80

Member
Feb 11, 2017
10
3
3
Prague
cPanel Access Level
Root Administrator
Hi,

I have an account that's set to PHP 5.5 DSO, but PHP-CLI uses system default 5.6, I need that account's PHP-CLI also to use 5.5

I tried to add an alias

Code:
alias php='/opt/cpanel/ea-php55/root/usr/bin/php'

and

alias php='/usr/local/bin/ea-php55'
at bottom in .bash_profile & .bashrc files in /home/account/ but that didn't seem to work

How can I set that account to use a specific PHP-CLI version (change htaccess, php.ini, bash_profile or other files)?

Thanks
 
Last edited:

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,301
363
Houston
HI @gizmo80

The following documentation on ea4 and the EA PHP CLI Package might be helpful: EasyApache 4 and the ea-php-cli Package - EasyApache 4 - cPanel Documentation


If you want to create an alias for that user you'd need to alias it to the path shown here:

Code:
$ /opt/cpanel/ea-php55/root/usr/bin/php --version
PHP 5.5.38 (cli) (built: Aug 28 2018 14:47:03)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
 
  • Love
Reactions: eugenevdm.host

gizmo80

Member
Feb 11, 2017
10
3
3
Prague
cPanel Access Level
Root Administrator
Hi Lauren,

so when I do command /opt/cpanel/ea-php55/root/usr/bin/php --version, it says I also have 5.5.38

I tried changing .bashrc to

Code:
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

# User specific aliases and functions
alias php=/opt/cpanel/ea-php55/root/usr/bin/php
this didn't work

file .bash_profile contains

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
which file should I change and how?

Thanks
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,301
363
Houston
Hi @gizmo80

That should work:

Code:
$ cat /home/myuser/.bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
alias php=/opt/cpanel/ea-php55/root/usr/bin/php
To test it:
Code:
# su myuser
[[email protected] ~]$ php -v
PHP 5.5.38 (cli) (built: Aug 28 2018 14:47:03)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

How did you test that this was/wasn't working?
 
  • Like
Reactions: gizmo80

DavyWDAC

Registered
Jul 18, 2019
1
0
1
St. Louis
cPanel Access Level
Root Administrator
Hi, so I've not had a lot of experience setting up Laravel in a cPanel environment and I have a problem getting the PHP version correct (7.2) when I enter php -v in the terminal.

Here's the setup:
CENTOS 6.10 kvm
PHP 7.0 is default system PHP version for all accounts that inherit.

I've setup a new cPanel account for the install and followed this tutorial for changing the document root (which worked fine): rosehosting.com/blog/how-to-install-laravel-on-a-cpanel-server/

So now, my public directory is /public_html/public instead of /public_html so I can install Laravel inside the /public_html folder and have the /public_html/public folder the portion exposed to the web.

After that, I set my account's domain to be PHP 7.2.

When I SSH in and test everything, when I'm inside /public_html/public, the PHP version shows up correctly. When I go up a level to the /public_html directory and test, it shows the system version of 7.0.

I've tried editing .bashrc and .bash_profile and attempted to locate a tutorial to help, but none of them that I could find would work and I actually ended up breaking something and having to re-create the cPanel account. Any advice would be helpful.
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello @DavyWDAC,

I moved your post into this thread as it looks to relate to the issue you are facing. Can you confirm if the previous posts here are helpful?

Thank you.