Mikey
28/08/06, 12:13
Onderstaand zijn de stappen die ik neem om suphp, php4, php5 op een centos machine icm directadmin te installeren. Dit naar voorbeeld van een thread op het directadmin forum. Ik ben zelf een tijd aan het stoeien geweest omdat ik de geplaatste oplossingen van bepaalde problemen nou niet echt de oplossing vond.
[root@test]#cd /usr/local/src/
[root@test]#wget http://de.php.net/get/php-5.1.5.tar.gz/from/this/mirror
[root@test]#wget http://de.php.net/get/php-4.4.4.tar.gz/from/this/mirror
[root@test]#wget http://downloads.mijn-sleutel.net/DA/suphp-0.6.1.tar.gz
Uitpakken van de zojuist gedownloade files.,
[root@test]#tar -zxvf php-5.1.5.tar.gz
[root@test]#tar -zxvf php-4.4.2.tar.gz
[root@test]#tar -zxvf suphp-0.6.1.tar.gz
# CONFIGURE & COMPILEN PHP4
[root@test]#cd php-4.4.2
[root@test]#./configure --prefix=/usr/local/php4 --enable-force-cgi-redirect --enable-fastcgi --with-config-file-path=/usr/local/etc/php4/cgi --with-curl --with-curl-dir=/usr/local/lib --with-gd --with-gd-dir=/usr/local/lib --with-gettext --with-jpeg-dir=/usr/local/lib --with-kerberos --with-mcrypt --with-mhash --with-mysql=/usr --with-pear --with-png-dir=/usr/local/lib --with-xml --with-zlib --with-zlib-dir=/usr/local/lib --with-zip --enable-bcmath --enable-calendar --enable-ftp --enable-magic-quotes --enable-sockets --enable-track-vars --enable-mbstring --enable-memory-limit
[root@test]#make
[root@test]#make install
# CONFIGURE & COMPILEN PHP5
[root@test]#cd ../php-5.1.5
[root@test]#./configure --prefix=/usr/local/php5 --enable-force-cgi-redirect --enable-fastcgi --with-config-file-path=/usr/local/etc/php5/cgi --with-curl --with-curl-dir=/usr/local/lib --with-gd --with-gd-dir=/usr/local/lib --with-gettext --with-jpeg-dir=/usr/local/lib --with-kerberos --with-mcrypt --with-mhash --with-mysql=/usr --with-pear --with-png-dir=/usr/local/lib --with-xml --with-zlib --with-zlib-dir=/usr/local/lib --with-zip --enable-bcmath --enable-calendar --enable-ftp --enable-magic-quotes --enable-sockets --enable-track-vars --enable-mbstring --enable-memory-limit
[root@test]#make
[root@test]#make install
# CONFIGURE & COMPILEN suPHP
[root@test]#cd ../suphp-0.6.1
[root@test]#./configure --prefix=/usr/local/suphp --sysconfdir=/usr/local/suphp/etc/ --with-apache-user=apache --with-setid-mode=force --with-apxs=/usr/sbin/apxs --disable-checkpath
[root@test]#make
[root@test]#make install
# Maken van de juiste directories
[root@test]#mkdir -p /usr/local/etc/php4/cgi
[root@test]#mkdir -p /usr/local/etc/php5/cgi
[root@test]#mkdir -p /usr/local/suphp/etc
# COPIEREN PHP CONFIG FILES
[root@test]#cp /usr/local/src/php-5.1.5/php.ini-dist /usr/local/etc/php5/cgi/php.ini
[root@test]#mkdir /usr/local/etc/php4/cgi/stdvrthost
[root@test]#cp /usr/local/src/php-4.4.2/php.ini-dist /usr/local/etc/php4/cgi/php.ini
[root@test]#cp /usr/local/src/php-4.4.2/php.ini-dist /usr/local/etc/php4/cgi/stdvrthos/php.ini
[root@test]#cp /usr/local/src/suphp-0.6.1/doc/suphp.conf-example /usr/local/suphp/etc/suphp.conf
Let op, ik copieer hier hele nieuwe ini files in, je moet deze aanpassen naar wens. Je kan evt de oude php.ini van de huidige php install erheen copieren. In de folder stdvrthost staat de php.ini voor de virtualhost waar ook webmail, phpmyadmin op draaien.
# Maak van de originele files
[root@test]#cp /usr/local/suphp/etc/suphp.conf suphp.conf.original
[root@test]#cp /etc/httpd/conf/httpd.conf httpd.conf.original
# Maak logfile voor suphp
touch /var/log/suphp.log
Voeg deze zelf toe aan bijvoorbeeld logrotate.
# Aanpassen van de suPHP configuratie
[root@test]#vi /usr/local/suphp/etc/suphp.conf
neem onderstaande gegevens over:
;User Apache is running as
webserver_user=apache
;Path all scripts have to be in
docroot=/
;Check wheter script is within DOCUMENT_ROOT
check_vhost_docroot=false
;Umask to set, specify in octal notation
umask=0022
; Minimum UID
min_uid=100
; Minimum GID
min_gid=500
[handlers]
;Handler for php-scripts
x-httpd-php=php:/usr/local/php4/bin/php
x-httpd-php5=php:/usr/local/php5/bin/php
# Aanpassen van de HTTPD.CONF
[root@test]#nano /etc/httpd/conf/httpd.conf
Na :
LoadModule php4_module /usr/lib/apache/libphp4.so
LoadModule frontpage_module /usr/lib/apache/mod_frontpage.so
LoadModule perl_module /usr/lib/apache/mod_perl.so
Voegtoe :
LoadModule suphp_module /usr/lib/apache/mod_suphp.so
na AddHandler cgi-script .cgi .pl
Voegtoe:
AddHandler x-httpd-php .php .inc .php4
AddHandler x-httpd-php5 .php5
suPHP_AddHandler x-httpd-php
suPHP_AddHandler x-httpd-php5
in <VirtualHost IP:80>
Voegtoe:
suPHP_Engine ON
suPHP_AddHandler x-httpd-php
suPHP_ConfigPath (/usr/local/etc/php4/cgi/stdvrthost)
suPHP_UserGroup apache apache
save httpd.conf
[root@test]#chown -R apache:apache /var/www/html/*
# Directadmin templates aanpassen:
[root@test]#cd /usr/local/directadmin/data/templates
[root@test]#cp virtual_host2* custom
[root@test]#cd custom
pas de 4 files aan.
Na |CGI|
Voegtoe:
Redirect 301 /webmail http://|IP|/webmail
Na |USECANONICALNAME|
Voegtoe:
suPHP_Engine |PHP|
suPHP_UserGroup |USER| |GROUP|
<Files *.php>
SetEnv PHPRC /usr/local/directadmin/data/users/|USER|/php4/
</Files>
<Files *.php5>
SetEnv PHPRC /usr/local/directadmin/data/users/|USER|/php5/
</Files>
doe dit bij alle 4 de bestanden, daarna rebuild all conf files.
[root@test]#echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
[root@test]#service httpd restart
Als het goed is zal httpd herstarten en gewoon naar behoren werken. Altans dat is bij mij wel het geval. De php files worden als php4 behandeld, php5 files worden als php5 behandel. Wil je nou dat alle php bestanden als php5 behandeld worden dan kun je dit oplossen door in het .htaccess het volgende te zetten: AddHandler x-httpd-php5 .php
Om php uit te zetten edit de httpd.conf van betreffend domein:
suPHP_Engine off
RemoveHandler .php
RemoveHandler .php5
Je kan na deze setup een ideale php.ini maken, heb je echter een gebruiker die toch wat aanpassingen nodig heeft, dan kun je per gebruiker een php.ini file gebruiken. Deze worden realtime gelezen. Om een gebruiker een eigen php.ini te geven maak je in de volgende directory twee directories aan, namelijk php4 en php5. Beide gebruiken hun eigen php.ini file(s).
/usr/local/directadmin/data/users/|USER|/ . Maak de directories aan en copier daarin de gewenste php.ini.
Mocht ik ergens gigantisch de plank misschieten, dan hoor ik dat uiteraard graag :)
[root@test]#cd /usr/local/src/
[root@test]#wget http://de.php.net/get/php-5.1.5.tar.gz/from/this/mirror
[root@test]#wget http://de.php.net/get/php-4.4.4.tar.gz/from/this/mirror
[root@test]#wget http://downloads.mijn-sleutel.net/DA/suphp-0.6.1.tar.gz
Uitpakken van de zojuist gedownloade files.,
[root@test]#tar -zxvf php-5.1.5.tar.gz
[root@test]#tar -zxvf php-4.4.2.tar.gz
[root@test]#tar -zxvf suphp-0.6.1.tar.gz
# CONFIGURE & COMPILEN PHP4
[root@test]#cd php-4.4.2
[root@test]#./configure --prefix=/usr/local/php4 --enable-force-cgi-redirect --enable-fastcgi --with-config-file-path=/usr/local/etc/php4/cgi --with-curl --with-curl-dir=/usr/local/lib --with-gd --with-gd-dir=/usr/local/lib --with-gettext --with-jpeg-dir=/usr/local/lib --with-kerberos --with-mcrypt --with-mhash --with-mysql=/usr --with-pear --with-png-dir=/usr/local/lib --with-xml --with-zlib --with-zlib-dir=/usr/local/lib --with-zip --enable-bcmath --enable-calendar --enable-ftp --enable-magic-quotes --enable-sockets --enable-track-vars --enable-mbstring --enable-memory-limit
[root@test]#make
[root@test]#make install
# CONFIGURE & COMPILEN PHP5
[root@test]#cd ../php-5.1.5
[root@test]#./configure --prefix=/usr/local/php5 --enable-force-cgi-redirect --enable-fastcgi --with-config-file-path=/usr/local/etc/php5/cgi --with-curl --with-curl-dir=/usr/local/lib --with-gd --with-gd-dir=/usr/local/lib --with-gettext --with-jpeg-dir=/usr/local/lib --with-kerberos --with-mcrypt --with-mhash --with-mysql=/usr --with-pear --with-png-dir=/usr/local/lib --with-xml --with-zlib --with-zlib-dir=/usr/local/lib --with-zip --enable-bcmath --enable-calendar --enable-ftp --enable-magic-quotes --enable-sockets --enable-track-vars --enable-mbstring --enable-memory-limit
[root@test]#make
[root@test]#make install
# CONFIGURE & COMPILEN suPHP
[root@test]#cd ../suphp-0.6.1
[root@test]#./configure --prefix=/usr/local/suphp --sysconfdir=/usr/local/suphp/etc/ --with-apache-user=apache --with-setid-mode=force --with-apxs=/usr/sbin/apxs --disable-checkpath
[root@test]#make
[root@test]#make install
# Maken van de juiste directories
[root@test]#mkdir -p /usr/local/etc/php4/cgi
[root@test]#mkdir -p /usr/local/etc/php5/cgi
[root@test]#mkdir -p /usr/local/suphp/etc
# COPIEREN PHP CONFIG FILES
[root@test]#cp /usr/local/src/php-5.1.5/php.ini-dist /usr/local/etc/php5/cgi/php.ini
[root@test]#mkdir /usr/local/etc/php4/cgi/stdvrthost
[root@test]#cp /usr/local/src/php-4.4.2/php.ini-dist /usr/local/etc/php4/cgi/php.ini
[root@test]#cp /usr/local/src/php-4.4.2/php.ini-dist /usr/local/etc/php4/cgi/stdvrthos/php.ini
[root@test]#cp /usr/local/src/suphp-0.6.1/doc/suphp.conf-example /usr/local/suphp/etc/suphp.conf
Let op, ik copieer hier hele nieuwe ini files in, je moet deze aanpassen naar wens. Je kan evt de oude php.ini van de huidige php install erheen copieren. In de folder stdvrthost staat de php.ini voor de virtualhost waar ook webmail, phpmyadmin op draaien.
# Maak van de originele files
[root@test]#cp /usr/local/suphp/etc/suphp.conf suphp.conf.original
[root@test]#cp /etc/httpd/conf/httpd.conf httpd.conf.original
# Maak logfile voor suphp
touch /var/log/suphp.log
Voeg deze zelf toe aan bijvoorbeeld logrotate.
# Aanpassen van de suPHP configuratie
[root@test]#vi /usr/local/suphp/etc/suphp.conf
neem onderstaande gegevens over:
;User Apache is running as
webserver_user=apache
;Path all scripts have to be in
docroot=/
;Check wheter script is within DOCUMENT_ROOT
check_vhost_docroot=false
;Umask to set, specify in octal notation
umask=0022
; Minimum UID
min_uid=100
; Minimum GID
min_gid=500
[handlers]
;Handler for php-scripts
x-httpd-php=php:/usr/local/php4/bin/php
x-httpd-php5=php:/usr/local/php5/bin/php
# Aanpassen van de HTTPD.CONF
[root@test]#nano /etc/httpd/conf/httpd.conf
Na :
LoadModule php4_module /usr/lib/apache/libphp4.so
LoadModule frontpage_module /usr/lib/apache/mod_frontpage.so
LoadModule perl_module /usr/lib/apache/mod_perl.so
Voegtoe :
LoadModule suphp_module /usr/lib/apache/mod_suphp.so
na AddHandler cgi-script .cgi .pl
Voegtoe:
AddHandler x-httpd-php .php .inc .php4
AddHandler x-httpd-php5 .php5
suPHP_AddHandler x-httpd-php
suPHP_AddHandler x-httpd-php5
in <VirtualHost IP:80>
Voegtoe:
suPHP_Engine ON
suPHP_AddHandler x-httpd-php
suPHP_ConfigPath (/usr/local/etc/php4/cgi/stdvrthost)
suPHP_UserGroup apache apache
save httpd.conf
[root@test]#chown -R apache:apache /var/www/html/*
# Directadmin templates aanpassen:
[root@test]#cd /usr/local/directadmin/data/templates
[root@test]#cp virtual_host2* custom
[root@test]#cd custom
pas de 4 files aan.
Na |CGI|
Voegtoe:
Redirect 301 /webmail http://|IP|/webmail
Na |USECANONICALNAME|
Voegtoe:
suPHP_Engine |PHP|
suPHP_UserGroup |USER| |GROUP|
<Files *.php>
SetEnv PHPRC /usr/local/directadmin/data/users/|USER|/php4/
</Files>
<Files *.php5>
SetEnv PHPRC /usr/local/directadmin/data/users/|USER|/php5/
</Files>
doe dit bij alle 4 de bestanden, daarna rebuild all conf files.
[root@test]#echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
[root@test]#service httpd restart
Als het goed is zal httpd herstarten en gewoon naar behoren werken. Altans dat is bij mij wel het geval. De php files worden als php4 behandeld, php5 files worden als php5 behandel. Wil je nou dat alle php bestanden als php5 behandeld worden dan kun je dit oplossen door in het .htaccess het volgende te zetten: AddHandler x-httpd-php5 .php
Om php uit te zetten edit de httpd.conf van betreffend domein:
suPHP_Engine off
RemoveHandler .php
RemoveHandler .php5
Je kan na deze setup een ideale php.ini maken, heb je echter een gebruiker die toch wat aanpassingen nodig heeft, dan kun je per gebruiker een php.ini file gebruiken. Deze worden realtime gelezen. Om een gebruiker een eigen php.ini te geven maak je in de volgende directory twee directories aan, namelijk php4 en php5. Beide gebruiken hun eigen php.ini file(s).
/usr/local/directadmin/data/users/|USER|/ . Maak de directories aan en copier daarin de gewenste php.ini.
Mocht ik ergens gigantisch de plank misschieten, dan hoor ik dat uiteraard graag :)