.php gets downloading instead of executing
Added by cnikos about 5 years ago
On a raspberry pi 2 I installed archlinuxarm
Then I installed lightttpd, php and php-fpm
In /srv/http I have a simple phpinfo.php file with the following code
<?php phpinfo(); ?>
My lighttpd configuration file is
server.port = 80 server.username = "http" server.groupname = "http" server.document-root = "/srv/http" server.errorlog = "/var/log/lighttpd/error.log" dir-listing.activate = "enable" index-file.names = ( "*.php", "index.html" ) mimetype.assign = ( ".html" => "text/html", ".txt" => "text/plain", ".css" => "text/css", ".js" => "application/x-javascript", ".jpg" => "image/jpeg", ".jpeg" => "image/jpeg", ".gif" => "image/gif", ".png" => "image/png", "" => "application/octet-stream" )
ls -l of /srv/http:
total 4 -rwxr-xr-x 1 http http 20 Apr 3 20:48 phpinfo.php
When I hit <raspberry pi ip>/phpinfo.php I get a message to download phpinfo.php instead of seeing the phpinfo page.
I can't find how to solve my problem. Any suggestions?
Replies (3)
RE: .php gets downloading instead of executing - Added by gstrauss about 5 years ago
You have not instructed lighttpd to do anything with your files besides the defaults (serve files, serve an index file on in a directory if one exists, or show a directory listing (since you have dir-listing.activate = "enable")
Please see documentation for mod_cgi or mod_fastcgi
Also, your syntax for index-file.names is incorrect. *.php is ambiguous. You might try index.php instead.
RE: .php gets downloading instead of executing - Added by cnikos about 5 years ago
Folder /srv/http has two files:
1.index.html
<html>Hello world</html>
2. index.php
<?php phpinfo(); ?>
ls -l of /srv/http:
total 1 -rwxr-xr-x 1 http http 27 Apr 5 12:00 index.html -rwxr-xr-x 1 http http 20 Apr 1 21:43 index.php
My lighttpd configuration file is
server.port = 80 server.username = "http" server.groupname = "http" server.document-root = "/srv/http" server.errorlog = "/var/log/lighttpd/error.log" server.modules += ( "mod_fastcgi" ) index-file.names = ( "index.php", "index.html" ) mimetype.assign = ( ".html" => "text/html", ".txt" => "text/plain", ".css" => "text/css", ".js" => "application/x-javascript", ".jpg" => "image/jpeg", ".jpeg" => "image/jpeg", ".gif" => "image/gif", ".png" => "image/png", "" => "application/octet-stream" )
When I hit <raspberry pi ip> in Firefox I get this message:
You have chosen to open: which is: application/octet-stream (20 bytes) from: <raspberry pi ip> Would you like to save this file?
When I hit <raspberry pi ip>/index.html or <raspberry pi ip>/index.php in Firefox I get this message:
You have chosen to open: index.html / index.php which is: HTML document / PHP script (20 bytes) from: <raspberry pi ip> What should Firefox do with this file?
I am new to lighttpd. I just want to test that lighttpd works and can serve pages. Can someone enlighten me what i miss.
Thanks in advance.
RE: .php gets downloading instead of executing - Added by gstrauss about 5 years ago
Please read my earlier response and follow the links.