Just as php python is a widely used easy to read and write on-the-fly interpreted language.


performance in the sense of data throughput or amount of prime numbers per second.

in terms of speed-of-data-processing the top list is like:

  1. C still (mostly) holds the performance crown 😀
  2. C++ and RUST (C++ often being faster, but RUST more (memory-wise) secure)
  3. GO (yes it is really a bit slower than RUST, wow who would have thought that?)
  4. PHP
  5. Python

(there is an interesting site that tries to benchmark languages by performance)

But if the large data can be processed incremental in smaller parts (process part A, maybe output A, process next part B…) also python and php can process GBytes of data.

python in control:

So for performance critical tasks python is actual just the “controller” that then calls C or or C++ or RUST or other binaries that can do the bulk data processing FAST.

So it is highly used for automation, that’s why RedHat’s yum and Ansible is using it.

There are actually at least 3 ways to make Python web compatible:

  1. write a webserver in python (it is actually not so complicated)
  2. install apache2 and forward web requests to python
  3. frameworks: flask, django

To be considered: when PHP scripts are run via Apache2: the timeout (usually maximum 30sec) after which the process is simply killed to not overload the multi threaded webserver.

When run from commandline (CLI) there is no such timeout and PHP scripts can run for longer.

1. write a webserver in python

2. install apache2 and forward web requests to python

hostnamectl; # tested on 
Virtualization: kvm
Operating System: Ubuntu 22.04.4 LTS 
Kernel: Linux 5.15.0-94-generic
Architecture: x86-64
su - root
apt update
apt install python3 apache2

# make python3 the default

ln -sv /usr/bin/python3 /usr/bin/py
ln -sv /usr/bin/python3 /usr/bin/python

# disable multi threading (for test system)
a2dismod mpm_event
a2enmod mpm_prefork cgi

# modify add this to default site config file
vim /etc/apache2/sites-enabled/000-default.conf
<Directory /var/www/html >
Options +ExecCGI
DirectoryIndex index.py
AddHandler cgi-script .py

# if mysql access is required
apt-get install python3-pip
pip3 install pymysql

# test apache2 config is ok
apachectl configtest
# restart apache2 to apply config
systemctl restart apache2

# make sure apache2 starts on boot
systemctl enable apache2

# check everything is running
systemctl status apache2

# create first python-web-test-file
vim /var/www/html/index.py

# -*- coding: UTF-8 -*-

import sys

print("Content-Type: text/html") # apache2-cgi: if this line is commented out, instead of running file.py, browser will download file.py
<h1>it works! apache2 is currently running python version:""" + sys.version + """</h1>
# give apache2 default user access
chown -R www-data: /var/www/
chmod ug+x /var/www/html/*.py

now start browser (firefox)

to go-to-ip-of-server (or) if graphical user interface is installed on server: http://localhost/ (apache2 test page)

now let’s test if it is running python 🙂

try browsing to:  http://localhost/index.py

if the developer sees this:

great! 🙂 celebrate!

if not: half so wild

open a second terminal and become root and launch this one-line-all-logs-live-monitoring-debugger.

it shall point to where the problem is. (typo in apache config, *.py scripts not marked executable… “permission denied”)


while the above way was tested and worked, to increase performance:

su - root
apt update
apt install libapache2-mod-python

but that ain’t working how it should


GNU Linux (Ubuntu but should work the same on Debian) how to setup Eclipse Python Development IDE PyDev in 2024 (including step debugging and all)

optional PyCharm Community edition or vscode it works fine with GNU Linux Debian

while vscode is one of the few M$ (true?) open source projects (written in TypeScript (which translates to JavaScript before runtime)) (languages, written in languages, that write languages)

it is actually it might infringe privacy wise:Data Collection. The software may collect information about the user and how the user uses the software, and send that to Microsoft unless it is on a internet-disconnected vm.

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!