Php5 / Mysql 4.1.9 Howto

Thanks Chris

I have installed php5 from source.

I used a minimum ./configure to only do some tests.

./configure
–prefix=/usr/php5/
–with-config-file-path=/etc/php5/
–with-config-file-scan-dir=/etc/php5/php.d/
–disable-debug
–disable-rpath
–with-xml
–with-zlib
–with-mysql

In an existing domain I added in at the bottom of the vhost config file :

AddHandler application/x-httpd-php5 .php5
Action application/x-httpd-php5 /bin/php
ScriptAlias /bin/ /usr/php5/bin/

and I have created a file called phpinfo.php5 with only


<?
phpinfo();
?>

When I launch it from the box

/usr/php5/bin/php /home/account/domain.tld/html/phpinfo.php5

it works great

but when I launch it from the web
http://hebergement-serveurs.fr/phpinfo.php5

I have an error 500 (internal server error)

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@hebergement-serveurs.fr and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Looking at the log I only have this

[error] [client xxx.xxx.xxx.xxx] Premature end of script headers: php

Any idea ?

Pascal

Erff of course !!!

It is due to the SuexecUserGroup xxxxxxx xxxxxxxx

I have commented it and now it works fine

http://hebergement-serveurs.fr/phpinfo.php5

Pascal

I ran into the same problem on my test machine but haven’t yet had the time to work on that. I’d like suEXEC working with PHP5 as a CGI but considering the paranoia around the suexec binary I can’t really tell what the problem is. If anyone has an idea I’d be greatfull for the time saver.

The /var/log/httpd/suexec* log files will shed light. suexec just does a series of checks before it execs a script. The usual culprits of suexec not working are:

  1. your script is owned by some other user than suexecusergroup says.

  2. the directory in which your script lives in owned by someone other than suexecusergroup

  3. the perms on your script and/or directory are too lenient (711 for each is fine).

The list goes on, and the options are better prioritized here:

http://httpd.apache.org/docs/suexec.html#model

Chris

Thanks Chris. I forgot about the minimum UID restriction. That’s what was killing me.

The error is because the doc_root is not set correctly

[2005-06-18 10:10:59]: uid: (xxx/zzzzz) gid: (xxx/xxx) cmd: php
[2005-06-18 10:10:59]: command not in docroot (/usr/php5/bin/php)

indeed, if I copy the php binary in /home/account/domain.tld/html/cgi-bin/
then chown it to the user account
and change the vhost config file to add

AddHandler application/x-httpd-php5 .php5
Action application/x-httpd-php5 /cgi-bin/php

ScriptAlias /cgi-bin/ /home/hebergem/hebergement-serveurs.fr/html/cgi-bin/

then it works fine

The pbm with this mean that I’ll have to copy the php binary in the doc root.
I wouldn’t do this for every account that would like to use php5

Have you got an idea

Pascal

Well pascal, that is the best thing to do I can think of at the moment. (You should be able to put the binary in the skel directory, and run some script to update the binary in everyone’s directories. Doing things this way is no different then having the individual users use their own cgi scripts, which just happen to be the php5 binary in this case. The other option is to modify the suEXEC binary to skip the requirement to have target UID/GID match script UID/GID.

What command are you trying to run from the browser here Pascal? php itself? Or are you trying to run a script that uses PHP #!/usr/bin/php style?

The php binary itself doesn’t need to be in the webspace, just as /usr/bin/perl doesn’t for perl based CGI scripts. There must be something else going on here.

Chris

Thanks Chris, I see that MySQL 4.1.10a has been on there for a bit, but PHP has not been upgraded to 5 yet. Are you planning on doing that today?

Going to try Paul, it’s been a bigger pain than I had wanted trying to generalize the php5 RPM. But I will give it a go today and let you know.

Chris

I try to launch a php script without the #!/usr/bin/php as Perl does (in my case #!/usr/php5/bin/php)

something like
http://domaine.com/script.php5

I understand what you mean, but the log did return me an suexec error

But idealy I don’t xant have to use the sembang

In my case when I used

Action application/x-httpd-php5 /usr/php5/bin/php

it didn’t work
Pascal

In fact I don’t know

It is the only rules I found to have php5 as cgi running on my box.

I’ve tried a lot of things but The only one that work is

  • to copy the php binary somewhere in the docroot
  • add
    AddHandler application/x-httpd-php5 .php5
    Action application/x-httpd-php5 /cgi-bin/php5-cgi

If I change the Action for the real path of the php binary it doesn’t work, if I add a ScriptAlias, it also doesn’t work.

Maybe there is a better way to have php5 as cgi and php4 as module both running on the same box, but I didn’t find it

Pascal

Well, the other option is to modify mod_php’s source code, adding “5” to everything. So you could load “mod_php5” instead of “mod_php”. If it checks for a modified content type as well, they may work along side each other. The problem here is you need to modify the code on EVERY release of PHP. Well… with a context-sensitive patch…

Paul,

You should be all set, I’ll be posting a HOWTO as soon as I get the info together.

Chris

PHP5 / MYSQL 4.1 MINI HOWTO:

We are not (yet) releasing RPMs as php5 is not officially part of the iworx RPM set so you’ll have to build the RPMs yourself. This HOWTO is meant to help you out getting a php5 / mysql 4.1 box running.

  1. Install rpmbuild if needed

yum install rpm-build

  1. Build the MySQL server for your platform. This needs to be done first so we can link php5 against it.

rpmbuild --rebuild --with rhe4x http://updates.interworx.info/iworx/SRPMS/experimental/mysql-4.1.12-100.iworx.src.rpm

NOTE: The previous command may barf out a list of dependencies that need to be installed. Just ‘yum install’ them and then continue.

  1. Upgrade your system to MySQL 4.1

rpm -Uvh RPMS/i386/mysql*.rpm

  1. Build PHP5 for your platform:

NOTE: YOU MAY NEED TO INSTALL MANY -DEVEL RPMS FOR THIS BUILD TO WORK.


rpmbuild --rebuild --with rhe4x http://updates.interworx.info/iworx/SRPMS/experimental/php-5.0.4-100.iworx.src.rpm

  1. Upgrade your system to PHP5

rpm -Uvh RPMS/i386/php*.rpm

This will give you php 5 + mysql 4.1 with php as a module and as a cgi.

THIS HAS ONLY BEEN TESTED ON CENTOS 4.1 AND CENTOS COMES WITH MYSQL 4.1 SO I USED THE DEFAULT MYSQL 4.1 FOR CENTOS (I.E. SKIP THE FIRST FEW STEPS UP TO THE PHP BUILD.

THIS IS STILL DEEMED EXPERIMENTAL AND WE CAN’T DIRECTLY SUPPORT IT AS WE WOULD OTHER IWORX PROVIDED RPMS.

Chris

Chris,

When you said php5 as module and CGI what do you mean exactly ?

Is php5 is installed in /usr under php5 or under php ?

the Apache conf file is created as php.conf or php5.conf ?

Well i’m sure you understand why I ask this :-p
Does this rpm will erase previous install of php4 or not ? ( :-p )

Thanks and well done as usual
Pascal

When you said php5 as module and CGI what do you mean exactly ?

Both /usr/bin/php and the .so that is run within apache are built / installed using the above method.

Is php5 is installed in /usr under php5 or under php ?

In “the usual spot”, the same as our php4 RPMs and the php cgi interpreter is at /usr/bin/php.

the Apache conf file is created as php.conf or php5.conf ?

php.conf

Well i’m sure you understand why I ask this :-p
Does this rpm will erase previous install of php4 or not ? ( :-p )

It will, it’s no different than upgrading from 4.3.9 to 4.3.11 it just seen as “the next version” and will overwrite previous versions.

Chris

A few questions:

How do we get the CLI version installed?

Would we have to build from source if not?

Would we still use “–with rhe4x” if we’re on CentOS 3.x?

Thanks,
Dave

Yep, you’d have to build from source and change the SPEC file to build the cli instead of the cgi Dave. And yes, you’ll still need the --with <distro> string.

Chris

OK, thanks. Could you clarify which <distro> string I’d need for CentOS 3.5? rhe3x? rhe4x?

Any plans to put out a supported MySQL 4.1 RPM?

-Dave