PHP files not being treated as PHP

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
JasonTC
Forum Commoner
Posts: 92
Joined: Wed Nov 02, 2005 11:05 am
Location: Grand Rapids, MI

PHP files not being treated as PHP

Post by JasonTC »

I have a fresh Debian install with PHP5 and Apache 2. When I try to view PHP pages in a browser, my browser tries to download the PHP page and asks me what type of program I would like to use to open it. I would take this to mean that the server is not parsing the PHP and outputting text like it's supposed to. Any idea what might be the problem?

Thanks,
Jason
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

How did you configure apache?
JasonTC
Forum Commoner
Posts: 92
Joined: Wed Nov 02, 2005 11:05 am
Location: Grand Rapids, MI

Post by JasonTC »

Initially, no configuration. Just did an apt-get install. Then I added something like this to my httpd.conf:

Code: Select all

<VirtualHost 127.0.0.1:80>
  ServerName askeet
  DocumentRoot "/home/sfprojects/askeet/web"
  DirectoryIndex index.php
  Alias /sf /usr/local/lib/php/data/symfony/web/sf

  <Directory "/home/sfprojects/askeet/web">
   AllowOverride All
  </Directory>
</VirtualHost>
I did not test any PHP scripts until after the change was made. After I took the change out and restarted Apache, it still didn't work.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Get rid of what you added there and try to add this instead:

Code: Select all

<VirtualHost *:80>
 ServerName localhost
 DocumentRoot "c:/apache2/htdocs"
 DirectoryIndex index.php index.html index.cgi index.htm default.htm default.html 403.htm 
</VirtualHost>

LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
Note that maybe you'll need to change it a bit. I assumed that you installed Apache in your C drive and named its folder "apache2". I also assumed that you installed PHP in your C drive and named its folder "php".
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

I'm not really a fan of apt-get when it comes down to configuring stuff... anyway, as oren already mentionned, where is the section that loads the module? and registers files with .php to application/x-httpd-php ?
JasonTC
Forum Commoner
Posts: 92
Joined: Wed Nov 02, 2005 11:05 am
Location: Grand Rapids, MI

Post by JasonTC »

I'm not really a fan of apt-get when it comes down to configuring stuff... anyway, as oren already mentionned, where is the section that loads the module? and registers files with .php to application/x-httpd-php ?
Actually, I don't think it exists and that's probably my problem. Oren showed a way to add that in Windows. How would I do it on Linux?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I'm not familiar with debian but
JasonTC wrote:Just did an apt-get install.
exactly what did you install?
There seem to be many many php packages like e.g. libapache2-mod-php5
Post Reply