18/10/2019 Apache run python script - Control WebPanel Wiki
Control WebPanel Wiki
Home / FAQ / Main Website / Forum / Facebook / YouTube
Have a question? Ask or enter a search term. SEARCH
Apache run python script
/ Apache / Apache run python script
January 14, 2016
Install python and run python scripts with apache on your
CentOS WebPanel server.
Install python
yum install python
Donate for Development
Check python version of CWP el7
python -V
Create a test script Categories
1 3rdParty
cd /home/USERNAME/public_html
19 Apache
mkdir cgi-bin
1 API
nano cgi-bin/test.py
1 Backups
3 Clusters
Now add the following python test script in the le:
5 Development
/home/USERNAME/public_html/cgi-bin/test.py
7 DNS
14 E-Mail
https://wiki.centos-webpanel.com/apache-run-python-script 1/4
18/10/2019 Apache run python script - Control WebPanel Wiki
7 FTP
#!/usr/bin/python
2 License
# enable debugging
import cgitb 2 Load-Balancers
cgitb.enable() 4 Migrations
print "Content-Type: text/plain\r\n\r\n"
9 MySQL
print
print "Hello World!" 1 Nginx
14 Other
3 Other Databases
Update test.py le and folder cgi-bin permissions
11 PHP
2 Scripts
chown -R USERNAME.USERNAME /home/USERNAME/public_
23 Security
html/cgi-bin
chmod +x /home/USERNAME/public_html/cgi-bin/test. 1 shell-scripts
py 2 SSL/AutoSSL
2 Testing
Now create .htaccess le to handle this script. 4 Updates
Add this test code bellow in your le 4 User-Panel
/home/USERNAME/public_html/cgi-bin/.htaccess
Popular Articles
Options +ExecCGI
AddHandler cgi-script .py How to change ssh
port
How to setup Name
Servers ?
Please don't forget to enable mod_suexec for
security reasons if you will have with multiple sites. MySQL Login details
How to install
Create File: /usr/local/apache/conf.d/mod_cgid.conf mod_pagespeed
Enable limited SFTP
access via SSH for
LoadModule cgid_module modules/mod_cgid.so
user
<IfModule cgid_module>
Import / Export
<Directory /home/*/public_html/cgi-bin/> MySQL Database
Options ExecCGI SymLinksifOwnerMatch
SetHandler cgi-script
AddHandler cgi-script .cgi .pl .py Latest Articles
Require all granted
AllowOverride All How to disable
php/php-fpm
selector
https://wiki.centos-webpanel.com/apache-run-python-script 2/4
18/10/2019 Apache run python script - Control WebPanel Wiki
</Directory> Action Hooks
</IfModule>
rsyslog not working
CWP Admin API
Now restart apache and you are ready to run your cgi-scripts.
cPanel to CWP
server convert
service httpd restart
How to Install and
Setup Node.Js on
CWP
Test if cgid module is now loaded
Add your Article
/usr/local/apache/bin/httpd -M|grep cgid
Want to Contribute?
Submit your Article
Test if suexec module is now loaded
Joint CWP Team
Join Our Development
/usr/local/apache/bin/httpd -M|grep suexec Team
Join Our Support Team
If module is loaded, you should get output containing this: Join Our Marketing Team
suexec_module (shared)
Join Our Designers Team
http://wiki.centos-webpanel.com/how-to-enable-
mod_suexec-with-apache Join Our Documentation
Team
Running cgi scripts requires some security so don't forget to
check this instructions
http://wiki.centos-webpanel.com/how-to-run-cgi-scripts-with-
apache
Now you can run your python script by using URL
http://domain.com/cgi-bin/test.py
Tagged: apache run python script
Related Articles
rsyslog not working How to install mod_cloud are
https://wiki.centos-webpanel.com/apache-run-python-script 3/4
18/10/2019 Apache run python script - Control WebPanel Wiki
Enabling Brotli compression Options FollowSymLinks not
on Apache allowed
WebServers vhost templates How to install Apache Solr
Home / FAQ / Main Website / Forum / Facebook / YouTube © Copyright, CWP Wiki
https://wiki.centos-webpanel.com/apache-run-python-script 4/4