Dylan
Dylan

Reputation: 47

why does browser attempt to download php file everytime I try to run that file?

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)

Upvotes: 0

Views: 7134

Answers (7)

Kinetic
Kinetic

Reputation: 1744

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.

Upvotes: 1

Viktor
Viktor

Reputation: 507

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...

Upvotes: -2

Thomas Ward
Thomas Ward

Reputation: 2752

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.

Upvotes: 1

Mike Brant
Mike Brant

Reputation: 71414

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

Upvotes: 2

vishal
vishal

Reputation: 705

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

Upvotes: 1

Kevin
Kevin

Reputation: 1

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 :)

Upvotes: 0

Henry Harris
Henry Harris

Reputation: 630

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.

Upvotes: 1

Related Questions