running local server .py prompts a text editor instead of opening page
<p>I have a file which currently works on my production site as mysite.com/pages/lister.py.</p>

<p>I am trying to build a local version of the site. The index.php works and other pages work, but when I go to a .py page like: localhost/pages/lister.py it doesnt change the site, it just asks if I want to use gedit to open the file.</p>

<p>My guess is that my local config is off somewhere, but I do not know where to start when approaching this problem. </p>

<p>NOTES:</p>

<p>I am running  a lamp server which I downloaded using <code>sudo apt-get install lamp-server^</code></p>

<p>and my apache config is <code>/etc/apache2/sites-available/000-default.conf</code> and contains:</p>

<pre><code>&lt;VirtualHost *:80&gt;

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/
    &lt;Directory /var/www/&gt;
        Options ExecCGI Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
        AddHandler cgi-script .py
    &lt;/Directory&gt;
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

&lt;/VirtualHost&gt;
</code></pre>

<p><strong>EDIT 1</strong></p>

<p>This may be the solution to my question but its not really working yet so idk yet.</p>

<p>I ran</p>

<pre><code>sudo a2enmod cgi
sudo service apache2 restart
</code></pre>

<p>and now it gives:</p>

<p>Internal Server Error</p>

<p>The server encountered an internal error or misconfiguration and was unable to complete your request.</p>

<p>Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.</p>

<p>More information about this error may be available in the server error log.
Apache/2.4.18 (Ubuntu) Server at localhost Port 80</p>

<p>My configuration for .pl and .py scripts that write HTML directly out to a page is the following:</p>

<pre><code>&lt;Directory "[put production path here]"&gt;
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride All
    Require all granted
&lt;/Directory&gt;
</code></pre>

<p>As I'm new to full stack work, I'm not sure if this is appropriate for your situation, but it might be worth a try.</p>

php python lamp