HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Tips/Tricks/Mods (http://www.howtoforge.com/forums/forumdisplay.php?f=19)
-   -   fastcgi and php with ispconfig (http://www.howtoforge.com/forums/showthread.php?t=4607)

tosser 31st May 2006 11:46

fastcgi and php with ispconfig
 
Howtos about fastcgi and php that are used or consulted:
http://www.debianhowto.de/de/howtos/...ache2_php-fcgi
http://www.syscp.de/wiki/contrib/PHP-FCGI-ger




Apache2 Install
In the first step you install apache2-mpm-worker
Code:

apt-get install apache2-common apache2-mpm-worker apache2-threaded-dev
if you restart the apache, but without mod_php. Because mod_php runs not with apache2-mpm-worker!
Code:

/etc/init.d/apache2 restart


Build Suexec
then you load the apache sources to compile a new suexec for fastcgi

Code:

cd /root
apt-get source apache2-common
cd apache2-2.0.54
cd upstream
cd tarballs
tar zxf httpd-2.0.51.tar.gz
cd httpd-2.0.54
cd support
vi suexec.h

edit the follow lines:
Code:

#define AP_HTTPD_USER "www"
with
Code:

#define AP_HTTPD_USER "www-data"
Code:

#define AP_LOG_EXEC DEFAULT_EXP_LOGFILEDIR "/suexec_log" /* Need me? */
with
Code:

#define AP_LOG_EXEC "/var/log/apache2/suexec.log" /* Need me? */
Code:

#define AP_DOC_ROOT DEFAULT_EXP_HTDOCSDIR
with
Code:

#define AP_DOC_ROOT "/var/www"
edit suexec.c
Code:

vi suexec.c
then insert the red market text into
Code:

  /* no file owner check
    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);
    }
  */


You need the apache2-header-files to compile suexec
Code:

cp -p /usr/include/apache2/* .
cp -p /usr/include/apr-0/* .

Code:

make suexec
then you must have:
Code:

ls -l suexec
-rwxr-xr-x  1 root root 20565 Aug  5 23:37 suexec

copy the suexec for fcgi to /usr/lib/apache2

Code:

cp suexec /usr/lib/apache2/suexec-fcgi
chmod 4755 /usr/lib/apache2/suexec-fcgi

you can delete the files, that you has downloaded with apt-source



Compile PHP (next step you can install by debian packages without compiling)
Code:

$ cd
mkdir php5
cd php5
wget http://de3.php.net/get/php-5.1.4.tar.gz/from/a/mirror
tar zxf php-5.1.4.tar.gz
cd php-5.1.4.tar.gz

./configure --enable-memory-limit --enable-force-cgi-redirect  \
--enable-track-vars --with-pcre-regex --with-mysql --without-sqlite \
--without-mm --enable-fastcgi --prefix=/home/_USER_/php5
make
make install

Important for php5 compilation and fastcgi:
Code:

apt-get install libmysqlclient14-dev libxml2-dev
./configure with: –enable-fastcgi –without-mm

if any packages missed use
Code:

apt-cache search "MISSED"
apt-get install "THE NEEDED PACKAGE



Inofficial Debain Packages for PHP5:
Code:

echo "deb http://people.debian.org/~dexter php5.1 sarge" >> /etc/apt/sources.list
echo "deb-src http://people.debian.org/~dexter php5.1 sarge" >> /etc/apt/sources.list
apt-get update
apt-get install php5.0 php5.0-common php5.0-fcgi apache2-mpm-worker

apt-get install apache2-mpm-worker because debian would like to remove it and install apache2-mpm-prefork again.



libapache2-mod-fastgi:
you musst edit the "/etc/apt/source.list" and include the non-free sector. It show like that:
Quote:

deb http://ftp.de.debian.org/debian/ stable main non-free
then
Code:

apt-get update
apt-get install libapache2-mod-fastcgi

then you edit the "/etc/apache2/mods-avaible/fastcgi.conf" with you favorit editor
Code:

vi /etc/apache2/mods-available/fastcgi.conf
it musst show like:

Quote:

<IfModule mod_fastcgi.c>

#temporary sockets are stored here, this must be at the top!
FastCgiIpcDir /var/lib/apache2/fastcgi

#config
FastCgiConfig -pass-header Authorization


FastCgiWrapper /usr/lib/apache2/suexec-fcgi


AddHandler php-fastcgi .php
<Location /php/php-fcgi-starter>
SetHandler fastcgi-script
Options +ExecCGI
</Location>
Action php-fastcgi /php/php-fcgi-starter

##ISPConfig add this by the installtion of it

##ISPConfig INSTALL## AddType ##ISPConfig INSTALL## application/x-httpd-php .php

<Directory "/var/www/">
AllowOverride None
Options +ExecCGI -MultiViews -Indexes
Order allow,deny
Allow from all
</Directory>
</IfModule>

-----------------------------------------------------------------------
now you must install ispconfig, if you didn't have it or you modify it by own
-----------------------------------------------------------------------


fast-cgi start script
You need a fast-cgi starter for all web hosts:
Code:

cd /root/ispconfig/standard_cgis
vi php-fcgi-starter

my php-fcgi-starter (with apache php5.1-fcgi package):
Quote:

#!/bin/sh
PHPRC="/etc/php5.1/fcgi/"
export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
exec /usr/bin/php5.1-fcgi
it must have root permissions:
Quote:

-rwxr-xr-x 1 root root 151 2006-05-31 00:15 php-fcgi-starter
that the webuser can excute it (by suexec) but can't edit it!


-----------------------------------------------------------------------
ispconfig copy this to /var/www/web*/ if you activate the standard_cgis, it a way to use fastcgi, but certainly not the optimal with ispconfig!
------------------------------------------------------------------------


modify ISPConfig
you must edit the vhost.conf.master
Code:

vi /root/ispconfig/isp/conf/vhost.conf.master
insert the red text:
Quote:

...
######################################
# Vhost: {SERVERNAME}
######################################
#
#
<VirtualHost {IP}>
{HTTPD_INCLUDE}
{SUEXEC}
ServerName {SERVERNAME}
ServerAdmin {SERVERADMIN}
DocumentRoot {DOCUMENTROOT}
{SERVERALIAS}
{DIRECTORYINDEX}
ScriptAlias /php/ {HTTPD_ROOT}/{WEB}/
{CGI}
ErrorLog {WEB_ERROR_LOG}
{PHP}
{SSI}
{WAP}
{ERRORALIAS}
{ERROR}
AliasMatch ^/~([^/]+)(/(.*))? {HTTPD_ROOT}/{WEB}/user/$1/web/$3
AliasMatch ^/users/([^/]+)(/(.*))? {HTTPD_ROOT}/{WEB}/user/$1/web/$3
{REWRITE_RULE}
{FRONTPAGE}
</VirtualHost>
#
{SSL}
#
....

-----------------------------------------------------------------------------
It's a simple way for fastcgi, php and ispconfig. But i searched a way without edit ispconfig files because updates of ispconfig.

I'm pleased to get feedback and better solutions ;)
and I hope that fastcgi find a way into the default installation of ispconfig :)

till 31st May 2006 18:03

Hi,

thanks for the ISPCOnfig FastCGI howto. We will integrate PHP FastCGI support in one of the next dev releases.

tosser 25th June 2006 16:43

I have update the howto, with a better solution.
so you can can activate or disable it with the php button.

Link to the current howto with the patchfile

falko 25th June 2006 21:01

The current version of tosser's tutorial can be found here: http://www.howtoforge.com/forums/showthread.php?t=4606
I close this thread (so that tosser does not need to update two threads); if you need the current version of the tutorial or have questions, please go to the other thread. :)


All times are GMT +2. The time now is 17:43.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.