Author Topic: [SOLVED]Can't seem to get Php(5) to work with apache2 on my local machine  (Read 611 times)

Offline cdbc

  • Full Member
  • ***
  • Posts: 59
Hi

I've just installed a m p on my pclos-lxde, including the php-CLI.
Apache is working, MySql is working and php-CLI is working, ...but php-scripts on the apache engine refuses to play ball. The httpd error log says all is ok, "gadmin" shows apache loading the module ok.
 ???

Could anyone tell me what i am missing...? I have searched the forum and google, but no cigar...

Thanks in advance.

Regards Benny
« Last Edit: January 11, 2011, 10:07:39 PM by cdbc »
Asus mb - P4@1.8 GHz - nVidia Vanta - d-link dx530 - onboard sound, running pclos-lxde,
Acer laptop - 2gigs of ram - running kde 4.8.3,
Lenovo laptop - db. core + 2 gigs of ram - running lxde

Offline kjpetrie

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3978
Re: Can't seem to get Php(5) to work with apache2 on my local machine
« Reply #1 on: January 05, 2011, 05:48:09 PM »
Are your scripts in the CGI bin or the Document root? For mod_php they need to be in document root. For the CLI PHP interpreter they would need to be in the CGI bin with a #!/<path to php>.

If they are under document root, do they end in .php or .html or something else? How are you telling Apache it needs to process them through PHP?

We need to know exactly how you have it set up.
-----------
KJP
-----------------------------------------------------------
PClos64 RC1 on Intel D945GCLF2 motherboard (Atom 330), 2GB DDR2 RAM, Maxtor STM325031, HL-DT-ST DVDRAM GSA-H42N, Amilo LSL 3220T monitor. Also Acer 5810TG (with custom kernel) and Asus eeePC 2G surf

Offline Texstar

  • Administrator
  • Super Villain
  • *****
  • Posts: 12483
Re: Can't seem to get Php(5) to work with apache2 on my local machine
« Reply #2 on: January 05, 2011, 05:52:34 PM »
Could anyone tell me what i am missing...?

task-lamp


Thanks to everyone who donates. You keep the servers running.

Offline cdbc

  • Full Member
  • ***
  • Posts: 59
Re: Can't seem to get Php(5) to work with apache2 on my local machine
« Reply #3 on: January 06, 2011, 08:56:35 AM »
Hi

Thanks TexStar, tried task-lamp. Nice package.
...but still no cigar... (noted it for next time though  ;))

Basically the problem persists (i'm probably a halfwitt).

. yes all documents are in the document root ie.: /var/www/html
. Yes they have 'php' extensions
. Apache loads the page, but shows the simple php-script 'as-is'. ie.: <?php echo "hello world"; ?>
. Same script (and others) run with whistles and bells in the CLI environment, no worries.
. As above, runs smooth online (apache server too)

I'll gather some more info, conf-file, error-logs etc. and post it here a little bit later...
Gotta go and be social tonight :)

Thanks for your help so far.

Regards - Benny
Asus mb - P4@1.8 GHz - nVidia Vanta - d-link dx530 - onboard sound, running pclos-lxde,
Acer laptop - 2gigs of ram - running kde 4.8.3,
Lenovo laptop - db. core + 2 gigs of ram - running lxde

Offline kjpetrie

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3978
Re: Can't seem to get Php(5) to work with apache2 on my local machine
« Reply #4 on: January 06, 2011, 10:14:37 AM »
You have the mime type for .php set wrong in the Apache configuration (/etc/httpd/modules.d/70_mod_php.conf). It should be AddType text/html .php .phtml. By default it is set as application/x-httpd-php, which is the mime type if you actually want to serve the script (for client-side parsing), rather than its server-parsed output!

You also need to ensure AddHandler php5-script .php .phtml is there as well.

-----------
KJP
-----------------------------------------------------------
PClos64 RC1 on Intel D945GCLF2 motherboard (Atom 330), 2GB DDR2 RAM, Maxtor STM325031, HL-DT-ST DVDRAM GSA-H42N, Amilo LSL 3220T monitor. Also Acer 5810TG (with custom kernel) and Asus eeePC 2G surf

Offline cdbc

  • Full Member
  • ***
  • Posts: 59
Re: Can't seem to get Php(5) to work with apache2 on my local machine
« Reply #5 on: January 09, 2011, 11:40:42 PM »
Hi
@kjpetrie, thank you for your advice.

70_mod_php_conf:
Code: [Select]
<IfDefine HAVE_PHP5>
    <IfModule !mod_php5.c>
LoadModule php5_module    extramodules/mod_php5.so
    </IfModule>
</IfDefine>

<IfModule mod_mime.c>
    AddType text/html .php
    AddType text/html .phtml
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .phtml
    AddType application/x-httpd-php-source .phps
</IfModule>

<IfModule mod_php5.c>
    <IfModule mod_dir.c>
DirectoryIndex index.php index.phtml
    </IfModule>
</IfModule>

I'm not quite sure where to put AddHandler php5-script .php .phtml

TIA Regards Benny
Asus mb - P4@1.8 GHz - nVidia Vanta - d-link dx530 - onboard sound, running pclos-lxde,
Acer laptop - 2gigs of ram - running kde 4.8.3,
Lenovo laptop - db. core + 2 gigs of ram - running lxde

Offline kjpetrie

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3978
Re: Can't seem to get Php(5) to work with apache2 on my local machine
« Reply #6 on: January 10, 2011, 11:15:00 AM »
Put it in <IfModule mod_mime.c> above the AddType entries. You also need to comment out the two old AddType entries so they don't override your new ones.
-----------
KJP
-----------------------------------------------------------
PClos64 RC1 on Intel D945GCLF2 motherboard (Atom 330), 2GB DDR2 RAM, Maxtor STM325031, HL-DT-ST DVDRAM GSA-H42N, Amilo LSL 3220T monitor. Also Acer 5810TG (with custom kernel) and Asus eeePC 2G surf

Offline cdbc

  • Full Member
  • ***
  • Posts: 59
Re: Can't seem to get Php(5) to work with apache2 on my local machine
« Reply #7 on: January 11, 2011, 01:17:59 AM »
Hi

@kjpetrie, Thank you.
I'll fiddle with it and see how it pans out. Will return later with my findings  :)

Regards - Benny
Asus mb - P4@1.8 GHz - nVidia Vanta - d-link dx530 - onboard sound, running pclos-lxde,
Acer laptop - 2gigs of ram - running kde 4.8.3,
Lenovo laptop - db. core + 2 gigs of ram - running lxde

Offline cdbc

  • Full Member
  • ***
  • Posts: 59
Hi

Wooohoooo.... Here we go...  :D

Everything rocks! Thanks alot guys.

Regards - Benny
Asus mb - P4@1.8 GHz - nVidia Vanta - d-link dx530 - onboard sound, running pclos-lxde,
Acer laptop - 2gigs of ram - running kde 4.8.3,
Lenovo laptop - db. core + 2 gigs of ram - running lxde