WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: LAMP settings - PHP not yet happy  (Read 5513 times)

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
LAMP settings - PHP not yet happy
« on: March 08, 2010, 02:51:43 AM »
I know that more than one person has been through this. I've read lots of manuals (apache, PHP, others ...), and I just can't get Apache + PHP working.

* TC 2.9
* Installed PHP, MySQL, Apache
* followed PHP info file instructions, repeatedly
* followed apache info file instructions, repeatedly

PHP works fine from the command line, but I can't get it to work from the browser. error_log says:

Code: [Select]
(8)Exec format error: exec of '/usr/local/htdocs/index.php' failed, referrer: http://127.0.0.1/
Premature end of script headers: index.php, referrer: http://127.0.0.1/

my index.php is simple:

Code: [Select]
<?php phpinfo(); ?>
I read Rob's advice about using lighttpd instead, but I'd reeeeely like this to work on apache. I am trying to duplicate a production server that runs debian+apache+drupal.

I am afraid that I have to recompile PHP and create the apache libphp5.so module, then load that in httpd.conf?

Any/all advice welcome!

Offline gutmensch

  • Administrator
  • Hero Member
  • *****
  • Posts: 605
  • I can make it disappear, have no fear!
    • remembrance blog
Re: LAMP settings - PHP not yet happy
« Reply #1 on: March 08, 2010, 03:15:37 AM »
Most likely this seems to be a user/group rights problem of the cgi script and apache.

Did you follow the advise in the apache help?

Quote
The most common cause of this problem is the script dying before sending the complete set of headers, or possibly any at all, to the server. To see if this is the case, try running the script standalone from an interactive session, rather than as a script under the server. If you get error messages, this is almost certainly the cause of the "premature end of script headers" message. Even if the CGI runs fine from the command line, remember that the environment and permissions may be different when running under the web server. The CGI can only access resources allowed for the User and Group  specified in your Apache configuration. In addition, the environment will not be the same as the one provided on the command line, but it can be adjusted using the directives provided by mod_env.
(found at http://httpd.apache.org/docs/1.3/misc/FAQ-F.html#premature-script-headers )
If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: LAMP settings - PHP not yet happy
« Reply #2 on: March 08, 2010, 06:47:43 AM »
I know that more than one person has been through this. I've read lots of manuals (apache, PHP, others ...), and I just can't get Apache + PHP working.

* TC 2.9
* Installed PHP, MySQL, Apache
* followed PHP info file instructions, repeatedly
* followed apache info file instructions, repeatedly

PHP works fine from the command line, but I can't get it to work from the browser. error_log says:

Code: [Select]
(8)Exec format error: exec of '/usr/local/htdocs/index.php' failed, referrer: http://127.0.0.1/
Premature end of script headers: index.php, referrer: http://127.0.0.1/

my index.php is simple:

Code: [Select]
<?php phpinfo(); ?>
I read Rob's advice about using lighttpd instead, but I'd reeeeely like this to work on apache. I am trying to duplicate a production server that runs debian+apache+drupal.

I am afraid that I have to recompile PHP and create the apache libphp5.so module, then load that in httpd.conf?

Any/all advice welcome!

I've been through this several times and have found that it's hard to beat using the Xampp stack approach. The only problem I have had is php moving to version 5.3 which deprecated several functions causing many php programs to fail. But now time has passed by and most programs of any significance have been updated. The Xampp team keeps the "stack" up to date and insures everything works "right out of the box". Give it a try to see how everything works and then you can always go back to the "build your own" approach.
big pc man

Offline roberts

  • Administrator
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: LAMP settings - PHP not yet happy
« Reply #3 on: March 08, 2010, 07:12:18 AM »
I too would suggest to look at XAMPP. It easily installs to /opt
Use Tiny Core's persistent /opt and you are set to go.
10+ Years Contributing to Linux Open Source Projects.

Offline robc

  • Sr. Member
  • ****
  • Posts: 447
Re: LAMP settings - PHP not yet happy
« Reply #4 on: March 08, 2010, 07:58:00 AM »
Have you used a #!/usr/local/bin/php shebang? I've found that since I updated php to 5.3.1 apache likes to have the shebang, though previously it didn't. You can also try /usr/local/bin/php-cgi

I find apache a bit cumbersome compared to lighttpd, both on resources and setup. Why do you want/need to use apache?
"Never give up! Never surrender!" - Commander Peter Quincy Taggart

"Make it so." - Captain Picard

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: LAMP settings - PHP not yet happy
« Reply #5 on: March 09, 2010, 01:41:19 AM »
gutmensch: that is something I hadn't seen - I'll definitely dig that one up and try.

robc/roberts/bigpcman: yep, downloading xampp now. I'll give that a try, too. As mentioned, I'm trying to copy a production server setup (commercial installation), but the xampp set is pretty close.

It will be the weekend again when I get time for this, but I'll report back!

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: LAMP settings - PHP not yet happy
« Reply #6 on: March 09, 2010, 05:35:42 AM »
gutmensch: that is something I hadn't seen - I'll definitely dig that one up and try.

robc/roberts/bigpcman: yep, downloading xampp now. I'll give that a try, too. As mentioned, I'm trying to copy a production server setup (commercial installation), but the xampp set is pretty close.

It will be the weekend again when I get time for this, but I'll report back!

As a reminder when unpacking Xampp, tar needs to have the 'f' switch at the end, as anything after that is taken as the input filename.  `tar zxvf somefile.tar.gz ` should work.
Also the Xampp scripts are written assuming the Bash shell is present so you will need to install the bash.tcz extension.

Edit: Here's a couple of mod tips for Xampp:

- To enable web pages with php code to run using an html extension (webpage.html) add to the apache config file (/opt/lampp/etc/httpd.conf) "AddType application/x-httpd-php .html"

- There are several php configuration options (/opt/lampp/etc/php.ini) that can be set for different execution environments such as development or production. I found it useful to change some of the options to use the production environment option. The most important option change for me was to turn off php error reporting (display_errors = Off) since I found that many php applications are still generating error messages when running under PHP 5.3. They run fine but mess up the html webpage rendering.
« Last Edit: March 09, 2010, 06:00:36 AM by bigpcman »
big pc man

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: LAMP settings - PHP not yet happy
« Reply #7 on: March 12, 2010, 04:11:35 PM »
roberts: thanks for suggesting persistent /opt. Only catch ... no luck getting persistent opt to work. I scourged the wiki + forum, but must have missed something important. If there are directions somewhere, I'll appreciate a point in the right direction.

I use persistent home, no problem (home=hda2). Easy to set, stable on reboot.

I've added boot arg opt=hda2, but I get nothing on hda2. /opt directory stills reside in RAM, so all is lost on reboot. I've tried a few things (I had/removed an hda2/opt directory from Xubuntu; changed permissions, etc. etc.).

Perhaps my backup file is overwriting the directory set by the boot code? I don't have /opt in filetool, though ... just files ...

EDIT: Yep, xampp working. Good to load firewall + bash extensions. I had to change the file permissions of opt/lampp/htdocs/xampp/lang.tmp to 666, but I think I'm good to go. I'll edit all the config files and such as I go.
« Last Edit: March 12, 2010, 04:24:21 PM by dentonlt »

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: LAMP settings - PHP not yet happy
« Reply #8 on: March 13, 2010, 03:25:19 AM »
/opt problem fixed. Totally don't know how or why, but ... it just works now.

Problem fixed, thread closed.