0

I have a PHP script that launches a Python script. It works fine when I am testing locally, but not on the shared hosting server. I've made the Python script, as well as the Python program files, executable for everyone using chmod. They are all installed under my /home/joeschome directory. I can run the Python script through an SSH terminal. What other troubleshooting steps can I take so that any web user can launch the Python script, via PHP?

EDIT

exec() does work with a hello.sh script. Python has all of the permissions through chmod. I even set up a virtual environment for python in the web root folder. I am getting exit status 127 for my python script. I can run it from the terminal just fine.

EDIT

It looks like the server is having a hard time finding the interpreter path when I just run it with

./hello.py

If I run it with an alias, it cooperates better.

python hello.py

If I want it to work with 3rd party modules, it prefers that I use the full path for the interpreter. I'll just use that for now.

/home/joe/public_html/my_venv/bin/python3.8 hello.py

3
  • 1
    I have very little experience with shared hosting, but are you sure exec() hasn't been disabled by your host? Is /home/joeschome accessible for the php/webserver user? And is your python file readable/executable by the php/webserver user? Those are the first three things I'd check.
    – Aaron
    Nov 7 '20 at 23:25
  • You are probably going to find that exec() is disabled on your server due to security issues
    – Steve
    Nov 7 '20 at 23:59
  • 1
    exec() works with a hello.sh script. Python has all of the permissions through chmod. I even set up a virtual environment for python in the web root folder. I am getting exit status 127 for my python script. I can run it from the terminal just fine.
    – Iktys
    Nov 8 '20 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.