So I'm not sure where to post.
I've spent 3 hours Googling, trying things, and nothing works; so here's what I know.
OS: CloudLinux
CPanel: Bare Metal License
Access: WHM / Root
I have a php app that requires jpegoptim and optipng. Thus far I've only tried jpegoptim.
As a root user in SSH; I can execute
and it works fine. Says it compressed.
The issue comes from when I attempt to run this via the PHP exec command. It returns error code 127. Contacted jpegoptim and they said:
Logged into the terminal / cpanel for my user, tried echo $PATH and it wasn't there; so I opened .bash_profile for the cpanel user, and added:
Then went back to Cpanel terminal, echo $PATH; and it was returning with the extra path to jpegoptim I affixed to it via the bash file.
Tested again; same thing. Went back to cpanel terminal; tried to run the command manually in terminal, and it said jpegoptim not found. However, if I use Putty, login as root; I can find it, run it, and it compresses. So that tells me it's something with the user, a perm, etc.
Went back to terminal, listed directories, and I cannot find the path at all, jpegoptim is not there: /usr/bin/jpegoptim
I also tried two separate version of jpegoptim;
v1.4.3 -> /usr/local/bin/jpegoptim
v1.4.6 -> /usr/bin/jpegoptim
Tried all the same steps for both installs, including setting the ENV path in bash_profile; same issue. If I execute it via terminal in cpanel on that user, command not found. However, root works fine.
I'm lost as to how I am supposed to allow my cpanel user to access that.
Also; I went into WHM, ensured that exec() was not in php's disabled functions; ran a few lines of code, and exec works.
I'm sure I've missed a few points, but here I am. I've tried every bit of research I can, and it's just a circle. I don't know where I should be posting this. I tried cpanel since it may involve how cpanel deals with permissions and users.
jpegoptim isn't in the EasyApache / WHM area; so I had to do it manually.
If I can get some sort of direction to go in; I would be more than grateful. I'm all for figuring things out on my own, but I'm really at a wall here.
Why Post on Cpanel Forums?
Because I tried the cpanel terminal; and cannot seem to locate jpegoptim at all, I'm wondering if there's a step or procedure I've missed which allows a cpanel account to access or see libraries such as jpegoptim.
As I said; I can see jpegoptim fine as root, but if I login as the cpanel user / terminal; I cannot locate the jpegoptim file at all.
I've spent 3 hours Googling, trying things, and nothing works; so here's what I know.
OS: CloudLinux
CPanel: Bare Metal License
Access: WHM / Root
I have a php app that requires jpegoptim and optipng. Thus far I've only tried jpegoptim.
As a root user in SSH; I can execute
Code:
/usr/local/bin/jpegoptim -P -p --max=50 image_name.jpg
The issue comes from when I attempt to run this via the PHP exec command. It returns error code 127. Contacted jpegoptim and they said:
So I spent an hour Googling.After discussing this with our team of developers, these errors are normally returned by your shell when any given command within your script is not found in any of the paths defined by the PATH system environment variable. This is an issue we aren't able to fix within the add-on because the error is actually coming from the server itself
Logged into the terminal / cpanel for my user, tried echo $PATH and it wasn't there; so I opened .bash_profile for the cpanel user, and added:
Code:
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/bin/jpegoptim
export PATH
Tested again; same thing. Went back to cpanel terminal; tried to run the command manually in terminal, and it said jpegoptim not found. However, if I use Putty, login as root; I can find it, run it, and it compresses. So that tells me it's something with the user, a perm, etc.
Went back to terminal, listed directories, and I cannot find the path at all, jpegoptim is not there: /usr/bin/jpegoptim
I also tried two separate version of jpegoptim;
v1.4.3 -> /usr/local/bin/jpegoptim
v1.4.6 -> /usr/bin/jpegoptim
Tried all the same steps for both installs, including setting the ENV path in bash_profile; same issue. If I execute it via terminal in cpanel on that user, command not found. However, root works fine.
I'm lost as to how I am supposed to allow my cpanel user to access that.
Also; I went into WHM, ensured that exec() was not in php's disabled functions; ran a few lines of code, and exec works.
I'm sure I've missed a few points, but here I am. I've tried every bit of research I can, and it's just a circle. I don't know where I should be posting this. I tried cpanel since it may involve how cpanel deals with permissions and users.
jpegoptim isn't in the EasyApache / WHM area; so I had to do it manually.
If I can get some sort of direction to go in; I would be more than grateful. I'm all for figuring things out on my own, but I'm really at a wall here.
Why Post on Cpanel Forums?
Because I tried the cpanel terminal; and cannot seem to locate jpegoptim at all, I'm wondering if there's a step or procedure I've missed which allows a cpanel account to access or see libraries such as jpegoptim.
As I said; I can see jpegoptim fine as root, but if I login as the cpanel user / terminal; I cannot locate the jpegoptim file at all.
Last edited: