In order to execute python scripts in Apache, you need to use an Apache module, like CGI module, to run. That is why assign cgi-script module as the handler for . py files (python scripts). Save and close the file.