Python Script not running on cPanel
On new cPanel version I'm not able to run the python script getting Internal Server Error
Files on cPanel to preview.
48167
Getting below error message on domain.com/cgi-bin/sample.py
Errors on cPanel: AH01xx5: attempt to invoke directory as script: /home/scriptsbrownarc/public_html/cgi-bin/, referer: domain.com/ Apache Handler also available: 48171 Kindly help me out to resolve this error to run python and perl scripts on cPanel. SSH Output:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@example.com[/EMAIL] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Errors on cPanel: AH01xx5: attempt to invoke directory as script: /home/scriptsbrownarc/public_html/cgi-bin/, referer: domain.com/ Apache Handler also available: 48171 Kindly help me out to resolve this error to run python and perl scripts on cPanel. SSH Output:
[scriptsbrownarc@panda ~]$ whereis python
python: /usr/bin/python2.7 /usr/bin/python /usr/lib/python2.7 /usr/lib64/python2.7 /usr/include/python2.7
[scriptsbrownarc@panda ~]$
-
Hello, The image you provided shows the Python script stored outside of the cgi-bin directory. Can you check to see if it opens correctly when moved within the cgi-bin directory? Thank you. 0 -
Hello @cPanelMichael sorry for bumping, but I have the exact same issue here. Same Apache handler, same .py script, and it is throwing the same "internal server error" in the browser no matter if I put the script inside cgi-bin or not. Content of test.py: #!/usr/bin/python print "Content-type: text/html\n" print "How to run Python scripts in cPanel"
Content of .htaccess:AddHandler cgi-script .py
test.py has permission 777 And on the terminal:# whereis python python: /usr/bin/python2.7-config /usr/bin/python2.7 /usr/bin/python /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /usr/share/man/man1/python.1.gz # /usr/bin/python cgi-bin/test.py Content-type: text/html How to run Python scripts in cPanel
So, it works in the console but not in the browser. Any advice? Thanks in advance! :)0 -
Hello @Kent Brockman, AddHandler cgi-script .py
This entry is not required in the .htaccess file.test.py has permission 777
Permissions should be set to 0755 instead of 0777. Using 0777 permissions will lead to the error message you reported. Let me know if changing the permissions to 0755 helps. Thank you.0 -
It worked great! Thanks!!!! 0 -
Hi @Kent Brockman, I'm glad to see that helped. I've marked this thread as solved. Thank you. 0 -
Hello, I am having the same problem solved. However, I changed permission of my python main script to 0755 from 0644. But still not working. I have activated a virtual environment for python 3.6 but when i type whereispython, it returns path for python 2.6 Kindly assist 0
Please sign in to leave a comment.
Comments
6 comments