Discussion about CustomBuild

Theres a slight issue with PHP4 and Apache 2.x which breaks the PHP fopen wrappers which in turn breaks squirrelmail. Definitely happens on FreeBSD at any rate.

The fix is to add -DFD_SETSIZE=4069 to the configured Makefile CFLAGS_CLEAN macro.

Heres a patch to add a condition in the doPHP4 function which checks to see if the Apache version is 2.0 or 2.2, if it is then it adds the -DFD_SETSIZE=4096 to the end of the CFLAGS_CLEAN macro.

Code:
diff -u build.orig build
--- build.orig	Thu Feb 14 15:47:26 2008
+++ build	Thu Feb 14 15:47:32 2008
@@ -1606,6 +1606,11 @@
 
 	echo "Done Configuration.";
 
+	# If Apache 2.0 or 2.2 then set FD_SETSIZE to 4096 to stop fopen from breaking.
+	if [ "${APACHE_OPT}" = "2.0" || "${APACHE_OPT}" = "2.2" ]; then
+		/usr/bin/perl -pi -e 's/^CFLAGS_CLEAN = (.*)$/CFLAGS_CLEAN = \1 -DFD_SETSIZE=4096/' Makefile
+	fi
+
 	while
 	echo "Trying to make php..."
 	do
 
If PHP is installed as CGI - it must have suPHP :) If it's installed as CLI - it doesn't work with suPHP.

I'm kind of confused... can someone clear this out for me please?

I asked how to have FastCGI without suPHP here to run XCache, but do I need to set custombuild to install php5 as CGI or CLI? And how can I compile FastCGI with apache2 through custombuild?

Thank you
 
i run xcache with CLI setup ;)

Are you using Apache suEXEC too? Is the PHP script running under the same user as the script file owner?
Because that is not an option for me... and I don't know if that is possible with the custombuild CLI/mod_php install.

Plus, I would like to have both PHP4 and PHP5, and I know that it is not possible with mod_php.
 
Debian etch
custombuild
PHP5.2.5
apache 2.2.8

not work xcache or eaccelerator

xcache Error :
Unable to load dynamic library '/usr/local/lib/php/extensions/xcache.so' - /usr/local/lib/php/extensions/xcache.so: undefined symbol: OnUpdateInt in Unknown on line 0
 
I asked how to have FastCGI without suPHP here to run XCache, but do I need to set custombuild to install php5 as CGI or CLI? And how can I compile FastCGI with apache2 through custombuild?

Since noone ever answered to my questions, I did it by myself, and this is what I have done for everyone who may consider using the same configuration.

1) run custombuild to install Apache 2.x with ./build apache (no ./build clean afterwards, we will need the Apache source later!)

2) run custombuild to install PHP4 CGI and PHP5 CGI (or just PHP5 CGI, your choice) with ./build php

3) download, compile and install FastCGI's mod_fastcgi as described here: http://www.fastcgi.com/mod_fastcgi/INSTALL.AP2

Of course top_dir is "/etc/httpd".
We will see later where to load the mod_fastcgi module.

4) download, compile and install XCache as described here: http://xcache.lighttpd.net/wiki/BuildingFromSource

Make sure to note the PATH of xcache.so when doing make install.
The xcache.ini file must be appended to /usr/local/etc/php5/cgi/php.ini (and /usr/local/etc/php4/cgi/php.ini if you want XCache there, not tested) and configured correctly.

5) modify /etc/httpd/conf/httpd.conf

Where there is:
Code:
LoadModule suphp_module /usr/lib/apache/mod_suphp.so
change with:
Code:
#LoadModule suphp_module /usr/lib/apache/mod_suphp.so
LoadModule fastcgi_module /usr/lib/apache/mod_fastcgi.so

Where there is:
Code:
#EnableSendfile off

#######################################################################################
# Do not change anything in included files, because they are rewritten by DirectAdmin #
change with:
Code:
#EnableSendfile off

#All FastCGI directives
Include conf/extra/httpd-fcgi.conf

#######################################################################################
# Do not change anything in included files, because they are rewritten by DirectAdmin #

6) create /etc/httpd/conf/extra/httpd-fcgi.conf

Content:
Code:
<IfModule mod_fastcgi.c>
ScriptAlias /fcgi4 /opt/fcgi/php4.fcgi
ScriptAlias /fcgi5 /opt/fcgi/php5.fcgi

<Directory "/opt/fcgi">
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
SetHandler fastcgi-script
</Directory>

AddHandler fastcgi-script .fcgi

FastCgiIpcDir /tmp
FastCgiWrapper /opt/fcgi/suexec
FastCgiConfig -singleThreshold 100 -killInterval 300 -autoUpdate -idle-timeout 240 -pass-header HTTP_AUTHORIZATION

AddType application/x-httpd-php4 .php4
AddType application/x-httpd-php5 .inc .php .cphp .phtml .php5

Action application/x-httpd-php4 /fcgi4
Action application/x-httpd-php5 /fcgi5

</IfModule>

Of course you can void all "php4" lines if you didn't install it.

7) create /opt/fcgi and put those files in there (then run chmod +x on them)

/opt/fcgi/php4.fcgi
Code:
#!/bin/sh
PHPRC="~"
export PHPRC
PHP_FCGI_CHILDREN=8
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=50000
export PHP_FCGI_MAX_REQUESTS
exec /usr/local/php4/bin/php
/opt/fcgi/php5.fcgi
Code:
#!/bin/sh
PHPRC="~"
export PHPRC
PHP_FCGI_CHILDREN=8
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=50000
export PHP_FCGI_MAX_REQUESTS
exec /usr/local/php5/bin/php-cgi

Please notice that PHP4 'fcgi' binary doesn't have a leading "-cgi". Of course you don't need the first file if you want just PHP5.

8) create a modded/unsecured suexec binary in the same directory!!!

This step is required because the phpX.fcgi scripts won't have the correct owner/group when calling the pages. For more informations read this: http://www.fastcgi.com/archives/fastcgi-developers/2005-October/003939.html

My patch is not half as good as his patch, but I can't find anywhere his patch.
EDIT: found it... it's exactly the same one :) then I found a third patch, still the same... I'm still looking for someone with a more secure way instead of this dirty and unsecure workaround.

Anyway here is how to create the new suexec binary: go to the custombuild directory, then into the httpd-version sources, and into the "support" directory.
Edit suexec.c and comment out lines 566-576. Result:
Code:
/*    if ((uid != dir_info.st_uid) ||
        (gid != dir_info.st_gid) ||
        (uid != prg_info.st_uid) ||
        (gid != prg_info.st_gid)) {
        log_err("target uid/gid (%ld/%ld) mismatch "
                "with directory (%ld/%ld) or program (%ld/%ld)\n",
                uid, gid,
                dir_info.st_uid, dir_info.st_gid,
                prg_info.st_uid, prg_info.st_gid);
        exit(120);
    }
*/

Now run 'make suexec', then copy the suexec binary to /opt/fcgi/suexec
Make the owner 'root' and chmod it +s (we need it SUID).

9) almost finished, we just need to patch an obviously forgotten IfModule from DirectAdmin's VirtualHosts files

Enter /usr/local/directadmin/data/templates/, copy virtual_host2.conf, virtual_host2_secure.conf, virtual_host2_secure_sub.conf, and virtual_host2_sub.conf to the "custom" directory, then modify all of them from this:
Code:
|*if SUPHP="1"|
                suPHP_Engine |PHP|
                suPHP_UserGroup |USER| |GROUP|
|*endif|
to this:
Code:
|*if SUPHP="1"|
                <IfModule mod_suphp.c>
                suPHP_Engine |PHP|
                suPHP_UserGroup |USER| |GROUP|
                </IfModule>
|*endif|

Then run this as root: echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue

Done! You have a running FastCGI+XCache+PHP[45] system!

WARNING:
Save your /etc/httpd/conf/httpd.conf somewhere, just in case: it's the only file custombuild and DirectAdmin should rewrite when updating/upgrading.
If you encounter any problem, just switch the two "LoadModule" lines in the same file, and you will return to a normal CGI/FastCGI+suPHP+PHP[45] system!
 
Last edited:
Im getting error when using custombuild 1.1 ./build all

Code:
Increasing memory limit to 20M...
Installing php...
Installing PHP SAPI module:       cgi
Installing PHP CGI into: /usr/local/php4/bin/
Installing PEAR environment:      /usr/local/lib/php/
make[1]: *** [install-pear-packages] Error 255
make: *** [install-pear] Error 2

Any help ?
 
Last edited:
The howto for FastCGI+XCache that I wrote in post #450 seems to cause a lot of 500 Internal Server Errors in a production environment (~500 requests a minute), no matter which values I put in the XCache or FastCGI configurations.

This happens either way on a small VPS and a large Core2Duo 4GB RAM dedicated server, so it's not a performance problem.

Both servers run pretty well with the default suPHP configuration, even with XCache activated (which of course doesn't work, because of the multitude of separated php-cgi processes spawned), therefore I guess the problems is caused by FastCGI.

Has anyone experienced this before or can tell me what's wrong with my setup?
 
im suffering from
service httpd configtest
httpd: Syntax error on line 17 of /etc/httpd/conf/httpd.conf: Cannot load /usr/lib/apache/libphp5.so into server: /usr/lib/apache/libphp5.so: cannot open shared object file: No such file or directory

any one able to help?
 
In general, the configtest isn't setup, but if you get the same error with:
sevice httpd start

then try:
Code:
cd /usr/local/directadmin/custombuild
./build php n
John
 
If configure fails try --with-xpm-dir=<DIR>
configure: error: freetype.h not found.

*** There was an error while trying to configure php. Check the configure/ap2/configure.php5 file

is what that came up with
 
I installed this script and updated MYSQL5 and then PHP5 cli, now I restarted httpd and I get the following error:
Invalid command 'php_admin_flag', perhaps mis-spelled or defined by a module not included in the server configuration

According to the tutorial my skin is outdated, I looked on the DA site and I only can find a tar of the enhanced skin. This skin I downloaded and I overwritten all files in the original skins folder, gave the echo command and even restart DA and of course httpd but still the same error.
In DA I cannot update DA itself as suggested if I do so it states:
Update not necessary
Details
You already have the most recent version of the program

So my problem is:
How do I start httpd again?
Where can I find these "new" version of the default templates which work, they are nowhere to be found on the DA website for download. I never installed other templates, the current ones are which where standard when installed.
I only have now the current templates: default, enhanced and power
DA is set to default to use template "enhanced"

Who can help me?
 
No i have no custom templates at all
Only the default templates of DA itself, also all rights are correct on the httpd.conf of the users...
DA version is 1.314000

I ran the following command:
Code:
./build update
./build all d
I got the following error now when I try to start httpd:
Starting httpd: httpd: Syntax error on line 18 of /etc/httpd/conf/httpd.conf: Cannot load /usr/lib/apache/mod_suphp.so into server: /usr/lib/apache/mod_suphp.so: undefined symbol: ap_table_get

I used the following confi:
Code:
#PHP settings. default_php possible values - 4 or 5
default_php=5
php4_cli=no
php4_cgi=no
php5_cli=no
php5_cgi=yes
zend=no

#Possible values - 4.1, 5.0 or 5.1
mysql=5.0
mysql_inst=yes

#Possible values - 1.3, 2.0 or 2.2
apache_ver=2.2

#Web applications
phpmyadmin=yes
squirrelmail=yes
roundcube=yes

#Mail options
exim=yes
mail-header-patch=yes
dovecot=no

#FTP options
proftpd=yes

#CustomBuild options
clean=yes

#CustomBuild 1.2 settings
php6_cli=no
php6_cgi=no
php_ini=no
#Possible values - recommended or dist
php_ini_type=recommended
cleanapache=no
fileserver=1
eximconf=no
 
Last edited:
Back
Top