LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-07-2008, 01:43 PM   #1
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 145

Rep: Reputation: 15
Apache2 and PHP5 no longer working


Hello,

I'm running Debian Sarge 3.1 and PHP5 and Apache2. Until Friday, they worked great. I installed python-pysqlite2 and now PHP won't work.

I've tried uninstalling and reinstalling PHP5, PHP4, etc. a2enmod says that PHP5 is enabled. I've restarted Apache numerous times. But when I try to access any PHP page, Firefox just downloads the PHP page code.

Where should I start?
 
Old 01-08-2008, 12:07 AM   #2
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 145

Original Poster
Rep: Reputation: 15
PHP is disabled

I can't get PHP to run. I've added the components and a2enmod says php5 is enabled, but each PHP page just downloads the code to the user's desktop.

Where should I start? I'm running Debian and Apache2
 
Old 01-08-2008, 12:55 AM   #3
thedonkdonk
Member
 
Registered: Oct 2005
Location: San Jose, CA
Distribution: Fedora, RHEL, CentOS
Posts: 136

Rep: Reputation: 16
Need to configure apache to parse PHP files. Add the following lines to your apache config file:
Code:
LoadModule php5_module             modules/libphp5.so
AddHandler php5-script             php
AddType    application/x-httpd-php php

Last edited by thedonkdonk; 01-08-2008 at 12:57 AM.
 
Old 01-08-2008, 07:18 AM   #4
thedonkdonk
Member
 
Registered: Oct 2005
Location: San Jose, CA
Distribution: Fedora, RHEL, CentOS
Posts: 136

Rep: Reputation: 16
You need to add the following lines to you apache configuration file:
Code:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php
AddType text/html .php
Then you need to restart apache.
 
Old 01-08-2008, 10:23 AM   #5
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 145

Original Poster
Rep: Reputation: 15
Silly question, but that should go in the apache2.conf and not httpd.conf, correct?
 
Old 01-08-2008, 10:31 AM   #6
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 145

Original Poster
Rep: Reputation: 15
I don't have libphp5.so on my system

How do I install it? I can't seem to find it, and apt-get install libphp5 failed as well.
 
Old 01-08-2008, 10:32 AM   #7
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 145

Original Poster
Rep: Reputation: 15
Thanks for replying to both posts

I can't seem to find libphp5.so on my system. apt-get install libphp5 didn't work either. Do you know what package it's a part of?
 
Old 01-08-2008, 11:01 AM   #8
Acron_0248
Member
 
Registered: Feb 2006
Location: Venezuela
Distribution: Gentoo
Posts: 453

Rep: Reputation: 33
Hi,

Install libapache2-mod-php5




Regards
 
Old 01-08-2008, 11:32 AM   #9
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 145

Original Poster
Rep: Reputation: 15
Installed that, thanks

So that installed but PHP pages still try to download instead of run. What should I check next?
 
Old 01-08-2008, 01:15 PM   #10
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
I merged your posts together as they seem to be related.
 
Old 01-08-2008, 01:20 PM   #11
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 145

Original Poster
Rep: Reputation: 15
Thanks

I didn't mean to post in two places; sorry for the mixup
 
Old 01-08-2008, 03:50 PM   #12
Acron_0248
Member
 
Registered: Feb 2006
Location: Venezuela
Distribution: Gentoo
Posts: 453

Rep: Reputation: 33
This is my initial configuration for Apache2 and PHP5:

/etc/apache2/mods-enabled/php5.conf:
Code:
<IfModule mod_php5.c>
  AddType application/x-httpd-php .php .phtml .php3
  AddType application/x-httpd-php-source .phps
</IfModule>

/etc/apache2/mods-enabled/php5.load:
Code:
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
/etc/apache2/mods-enabled/mime.conf (make sure this is inside the tags <IfModule mod_mime.c> and </IfModule>):
Code:
# Mime Type for PHP5
AddType application/x-httpd-php		php

That's all you need so apache can run php code.


If you make any reconfiguration at the config files, make sure restart the apache2 server




Regards

Last edited by Acron_0248; 01-08-2008 at 03:51 PM.
 
Old 01-08-2008, 04:31 PM   #13
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 145

Original Poster
Rep: Reputation: 15
I'm almost there

Okay, I'm almost in the clear.

PHP seems to be working now. If I go directly to the PHP page (for example, www.mysite.com/index.php) it works.

What isn't working is that I used to just go to the directory (i.e. www.mysite.com/pictures) and it would automatically go to index.php.

I forgot how to set this in Apache2; can you help me?

Thanks for all of your help. It's nice to have this back up!
 
Old 01-08-2008, 06:14 PM   #14
Acron_0248
Member
 
Registered: Feb 2006
Location: Venezuela
Distribution: Gentoo
Posts: 453

Rep: Reputation: 33
/etc/apache2/mods-enabled/dir.conf:
Code:
<IfModule mod_dir.c>

          DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

</IfModule>

Regards
 
Old 01-08-2008, 06:30 PM   #15
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 145

Original Poster
Rep: Reputation: 15
Thanks

Looks like I'm okay now. Don't know what happened. I definitely did /etc/init.d/apache2 restart after every change, but I guess I must have missed a step.

Thanks for all yer help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php5 not working with apache2 in debian 4.0 mohtasham1983 Linux - Server 2 08-08-2007 09:19 PM
Apache2 and php5 barrythai Mandriva 2 05-08-2007 08:09 AM
Apache2 and php5 not working RestInPieces Fedora 2 06-27-2006 06:27 PM
php5 not working on apache2 akp913 Debian 1 06-26-2006 03:28 AM
Apache2 and PHP5 rul3r Slackware 7 09-11-2005 05:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration