mardi 6 février 2018

How to specify custom Apache type and handler?

I want to have Apache run python scripts using /bin/env python. I tried putting this in my /etc/apache2/apache.conf

<Directory /var/www/>
    Options Indexes FollowSymLinks
    Options +ExecCGI
    Order allow,deny
    Allow from all
    AllowOverride None
    Require all granted

    AddType application/pyscript .py
    AddHandler pyscript .py
    Action pyscript "/usr/bin/env python"

</Directory>

When I try hitting localhost/hello.py, the browser gives me the save file UI. The access log says:

"GET /hello.py HTTP/1.1" 200 589 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.323 9.132 Safari/537.36"

I tried changing application/pyscript to just pyscript. When I do that, the error log says

[mime:warn] [pid 15873] AH01599: Cannot get media type from 'pyscript'

and the browser tells me

The requested URL /usr/bin/env python/hello.py was not found on this server.




Aucun commentaire:

Enregistrer un commentaire