I have a LAMP environment on Ubuntu and trying to get it to execute Python scripts. All of the files sit under
/var/www/euromemes.com/public_html and all the scripts are in
I started playing with this and basically I had access to all the files, but they were just displaying code, not executing. Example: http://euromemes.com/cgi-bin/browser.py
After playing around I’m now not even able to access those files (404 on the files and 403 on cgi-bin). I reverted back to all previous changes, the only thing that is changed was me running “sudo a2enmod cgi”.
[QUICK UPDATE: I can confirm that once I run sudo a2enmod cgi that gives me the 403 and 404 errors as described above. Without it running it simply displays the .py file code without executing it.]
I tried editing /etc/apache2/apache2.conf and currently it has this in there:
<Directory /> Options FollowSymLinks AllowOverride None Require all denied </Directory> <Directory /usr/share> AllowOverride None Require all granted </Directory> <Directory /var/www/> Options ExecCGI Indexes FollowSymLinks AddHandler cgi-script .py AllowOverride All Require all granted </Directory>
This isn’t getting the job done… Not sure why this is happening, I thought Options ExecCGI and AddHandler cgi-script .py would be enough. Also not entirely sure if I should be editing apache2.conf or whatever .conf files I have in etc/apache2/sites-available, possibly 000-default.conf? I would want all my sites (not just euromemes.com, but all in /var/www) to be able to handle Python scripts.
Thanks in advance!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Click below to sign up and get $100 of credit to try our products over 60 days!