• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Resolved Plex Onyx to work with Python

Carlos Antolinez

New Pleskian
Hi, I would like to work with python in a server Centos 7 with Plesk Onyx version 17.0.17.

I can give certain information about my configuration:
1) In Tools & Settings > Apache Web Server > check python. I no have this options to check it.

2)
In my console I have :
[root@server1 ~]# python
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

3)
Mod python is not installed
[root@server1 ~]# rpm -q mod_python
package mod_python is not installed

And finally, when I execute a file test2.py I have this result:
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

print "Content-Type: text/plain;charset=utf-8"
print

print "Hello World!"

At this point I don´t know what is exactly my problem. I´ve read about this but I not have nothing especific to do. Someone could help me?

Thanks a lot

Carlos
 
Hi Carlos Antolinez,

pls. note: "mod_python" is not shipped by CentOS anymore. Pls. consider to compile "mod_python" with these example commands:

Pls. start with some basics:
Code:
yum group install "Development Tools"

or

yum groupinstall "Development Tools"
or/and
Code:
yum install gcc-c++ pcre-devel zlib-devel make unzip

Install "python-devel" and "httpd-devel":
Code:
yum -y install python-devel httpd-devel

Get the latest "mod_python" source with "wget" from => Index of /dist
Code:
cd /usr/local/src/
wget http://dist.modpython.org/dist/mod_python-3.5.0.tgz
tar xfz mod_python-3.5.0.tgz

Configure and compile your "mod_python" - source:
Code:
cd /usr/local/src/mod_python-3.5.0
./configure
make
make install

Finally, enable the module for your apache - server with for example:
Code:
echo 'LoadModule python_module modules/mod_python.so' > /etc/httpd/conf.modules.d/99-python.conf
systemctl restart httpd.service


Could you pls. explain HOW you executed "test2.py"? Consider to use the example commands
Code:
cd /var/www/vhosts/YOUR-DOMAIN.COM/httpdocs
./test2.py

Did you probably miss to set the correct permissions for "test2.py"? ( consider to use: chmod +x /var/www/vhosts/YOUR-DOMAIN.COM/httpdocs/test2.py )
 
Last edited by a moderator:
Thank you very much UFHH01. I´ll try your instructions.

Regarding your question about I executed "test2.py" : I´ve tried from crhome because I want to work with python in web. I´m very new with Python and I´m reading about to learn, yet.
 
Hello,

Nowadays almost no-one uses mod_python to run and applications - you can consider to use passenger to host the python application, especially you use modern python frameworks
 
Hi Mizar, how can I do that.

In fact I want to try test a mqttwarn (GitHub - jpmens/mqttwarn: Subscribe to MQTT topics (with wildcards) and notifiy pluggable services ) in a server centos 7 with plesk, but I can´t do it. I suppuse that the problem is executing python.
------------------------------------------
I followed the steps of UFHH01, and all was well but when I try finally( systemctl restart httpd.service) I have this error
[root@server1 Python-3.5.2]# systemctl restart httpd.service
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
 
Hi Carlos Antolinez,

when you see outputs like
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
... pls. FOLLOW the suggestions, in order to investigate possible issues/errors/problems, because no one is able to guess, what the issue/error/problem might be. ;)


If the issue/error/problem is because you recently added "echo 'LoadModule python_module modules/mod_python.so' > /etc/httpd/conf.modules.d/99-python.conf", pls. CHECK, that "mod_python.so" exist at the defined path and correct the path if necessary. Use a "locate" - command for example ( requires "mlocate" to be installed on your server - consider to use the => Search | Plesk Forum , if you need more informations to installation and usage of "mlocate" ), which should point you to the exact location of "mod_python.so" on your server. ;)
 
Ok, thank you very much for all, I´ll try to do all of you said and additionaly I go to learn (reading) about this, I think that with your tips and a little bit information I´ll resolve this milestone.
 
Back
Top