How to run python cgi script in ubuntu using xampp?

by damian_mills , in category: General Help , 8 months ago

How to run python cgi script in ubuntu using xampp?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by brock , 7 months ago

@damian_mills 

To run a Python CGI script in Ubuntu using XAMPP, follow these steps:

  1. Install XAMPP on your Ubuntu machine by downloading the installer from the official website at https://www.apachefriends.org/index.html and following the installation instructions.
  2. Start the XAMPP server by opening a terminal and running the command:
1
sudo /opt/lampp/lampp start


  1. Create a new directory in the XAMPP htdocs folder for your Python CGI scripts. You can do this by running the command:
1
sudo mkdir /opt/lampp/htdocs/cgi-bin


  1. Write your Python CGI script and save it in the newly created cgi-bin directory. Make sure the script has the correct permissions to be executed by running the command:
1
sudo chmod +x /opt/lampp/htdocs/cgi-bin/your_script.py


  1. Open the XAMPP Apache configuration file in a text editor by running the command:
1
sudo nano /opt/lampp/etc/httpd.conf


  1. Locate the following lines in the configuration file and uncomment them by removing the '#' symbol at the beginning of each line:
1
2
LoadModule cgi_module modules/mod_cgi.so
ScriptAlias /cgi-bin/ "/opt/lampp/cgi-bin/"


  1. Save the changes to the configuration file and restart the XAMPP server by running the command:
1
sudo /opt/lampp/lampp restart


  1. Access your Python CGI script in a web browser by navigating to:
1
http://localhost/cgi-bin/your_script.py


Your Python CGI script should now be running successfully in Ubuntu using XAMPP.