0

I'm just starting out with using php and am having quite a bit of trouble. every time I attept to launch my php page my browser tries to have me download it. my php code is below.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php $uri = $_SERVER['REQUEST_URI'];?>
<?php echo $uri;?>
<?php $host = $_SERVER['HTTP_HOST'];?>
<?php echo $host;?>
<?php echo $_SERVER['REQUEST_URI'];?>
<?php echo $_SERVER['HTTP_HOST'];?>
</body>
</html>

If you could help then please tell me why is this happening, how do I fix it, and is there something I can do to prevent this from happening in the future. Thanks for any help.

info:

Server-LightTPD for windows
Editors attempted-notepad and dreamweaver
*most success with dreamweaver...(I think)
Dylan
  • 47
  • 2
  • 8

7 Answers7

2

You need to configure your lighty server to use PHP. Here are sample instructions for installing PHP as fast CGI on lighty.

https://wiki.ubuntu.com/Lighttpd%2BPHP

Mike Brant
  • 70,514
  • 10
  • 99
  • 103
  • this is probabaly exactly what i'm looking for, except that i'm using Windows7, do you happen to know how to do it on windows version. found here(http://en.wlmp-project.net/downloads.php) – Dylan Jul 30 '12 at 19:24
  • ..........WOW I FEEL STUPID, thank you for your comment as it made me go back to that page so i could see that the lightTPD for windows doesn't seem to have php support where as on down from that is this 'WLMP Webserver Package A LightTPD based web server package built for Windows based systems. The package also contains the following components: OpenSSL, MySQL, PHP, MiniPerl and phpMyAdmin.' – Dylan Jul 30 '12 at 19:33
  • You are naming you page *.php right? I would assume that you WLMP would be configured to recognize that extension by default. Regardless the behavior you are seeing is exactly what one would expect if the server request was not being passed to PHP to handle. – Mike Brant Jul 30 '12 at 19:54
  • come on, give me some credit, i'm not THAT bad. (yes the extention is .php) – Dylan Jul 30 '12 at 19:55
  • @Dylan Just checking I've seen stranger things :) – Mike Brant Jul 30 '12 at 19:58
  • lol. Make sure you've got the sqlite libs installed for php (`php5-sqlite` on ubuntu, i forget the Debian package name) – Thomas Ward Jul 31 '12 at 13:13
  • yep, I've got it all working...now back to blowing up my application to add more onto it then hack away till it works again XP yay.....and to think...I plan to do this for a living....it's been 2 monthes. – Dylan Jul 31 '12 at 18:32
1

Download Apache then...

You'll want to make sure that Apache has been told that .php files should be treated as PHP scripts. That means one of the following:

LoadModule php5_module        modules/libphp5.so    # on windows, this'd be a .dll instead
AddHandler php5-script php 

and/or

AddType application/x-httpd-php php
in your httpd.conf file.
Henry Harris
  • 620
  • 4
  • 7
  • 18
1

Did you installed Apache, PHP? If you beginner then install wamp or xamp. A packages for PHP, Apache, Mysql.

vishal
  • 685
  • 2
  • 6
  • 9
1

I'm not a user of lighttpd, but you'll need to modify the lighttpd configs for your sites to proxy the data to PHP, so that PHP returns the data. In nginx, which I use, that's done by the proxy_pass command. There is likely such a command (not exact but similar) in which you can proxy information to in lighttpd. If you're on Debian, you can use php-fpm (php5-fpm on Ubuntu) to run this, and then proxy to a tcp socket on 127.0.0.1. Note that the latest php5-fpm is configured to use UNIX sockets instead of a tcp listener.

Also, i believe you can only use TCP sockets with lighttpd, but i have not gone in and checked this in depth.

Thomas Ward
  • 2,714
  • 7
  • 36
  • 51
1

Sounds like you haven't got php enabled on your server install. You may need to add the following to your lighttpd.conf

fastcgi.server = (
    ".php" => (
            (
                   "bin-path" => "C:\Path\to\php-cgi.exe -c C:\Path\to\php.ini",
                   "socket" => "C:\tmp\php.socket",
                   "max-procs" => 2,
                   "idle-timeout" => 20,
                   "bin-environment" => (
                       "PHP_FCGI_CHILDREN" => "2",
                       "PHP_FCGI_MAX_REQUESTS" => "1000"
                    )
            )
      )
)

Failing that download the WLMP project from here http://en.wlmp-project.net/ which includes Lighttpd, MySQL and PHP in one neat bundle.

Kinetic
  • 1,714
  • 1
  • 13
  • 38
  • yeah, that was it, I hadn't configured the php.ini and lighttpd.conf correctly. I already got it, but thank you anyway. – Dylan Aug 14 '12 at 12:55
0

First you need to download Apache, I suggest XAMPP and place the .PHP file inside the HTdocs folder that comes with Apache. Start the Apache server and open a webbrowser then go to http:// localhost/YOUFILEHERE.PHP

Sounds like you're trying to open the PHP file localy without passing a PHP server :)

Kevin
  • 1
-2

I've never heard of LightTPD, but XAMPP (Apache, MySQL, PHP package) has served me well and need no configuring at all, which I'm guessing is what your LightTPD installation requires.

http://www.apachefriends.org/en/xampp-windows.html

If you're open to easy alternatives, that is...

Thomas Ward
  • 2,714
  • 7
  • 36
  • 51
Viktor
  • 487
  • 2
  • 8
  • 26
  • if you have a question about why you were downvoted, that question should not be part of your answer. – Thomas Ward Jul 30 '12 at 19:16
  • that won't work as LightLPD is one of the few servers I found that accually states that it supporrts SQLite. – Dylan Jul 30 '12 at 19:18
  • Sorry, I couldn't guess that from your original post. Although, I think XAMPP comes with SQLite. "The distribution for Windows 2000, 2003, XP, Vista, and 7. This version contains: Apache, MySQL, PHP + PEAR, Perl, mod_php, mod_perl, mod_ssl, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, FileZilla FTP Server, mcrypt, eAccelerator, **SQLite**, and WEB-DAV + mod_auth_mysql." In fact, I've used SQLite with XAMPP. – Viktor Jul 30 '12 at 19:21
  • Isnt SQLite support a php-level library? Last I checked there *is* a php sqlite library. – Thomas Ward Jul 30 '12 at 19:24
  • i'm not sure, but i think that may be mySQL – Dylan Jul 30 '12 at 19:27
  • it's fine, as you'll read above the issue seems to have been born of stupidity – Dylan Jul 30 '12 at 19:37
  • I still feel the down vote is a little unsatisfactory, who ever it was. (Not in the question now!) – Viktor Jul 30 '12 at 19:44
  • @Dylan i am absolutely certain there is a php library for mysql, i'm pretty certain (at least in Debian and Ubuntu) there's a php-level sqlite library... – Thomas Ward Jul 30 '12 at 20:00
  • @Dylan after doing some checking once i got my internet working, the PHP library (in Ubuntu) is php5-sqlite, and pulls in sqlite dependencies as well. In case there's an SQLite db involved for PHP – Thomas Ward Jul 31 '12 at 13:11