Python avec mod_python
Python peut être préféré pour des applications nécessitant des capacités de calcul scientifique ou de machine learning.
sudo apt install libapache2-mod-python
sudo a2enmod python
 <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
     <Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
     </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost/"
    </FilesMatch>
  AddHandler mod_python .py
  PythonHandler mod_python.publisher
  PythonDebug On
 </VirtualHost>
sudo systemctl restart apache2
                              
                            
sudo nano /var/www/html/fichier.py
from mod_python import apache
def handler(req):
    req.content_type = 'text/plain'
    req.write("Hello World from Python using mod_python!")
    return apache.OK
http://your_server_ip/fichier.py