Installation of customized PHP


#1

Hello!
I need the enable-register_globals and enable-safe_mode. I wrote it in php.ini - but it didn’t work. I got Off for this features. Some features is working (like allow_url_fopen - On).
This is the code of installation - what is wrong there:

#!/bin/bash

Abort on any errors

set -e

The domain in which to install the PHP CGI script.

export DOMAIN="…"

Update version information here.

PHP="php-4.4.4"
LIBICONV="libiconv-1.10"
LIBMCRYPT="libmcrypt-2.5.7"
LIBXML2=“libxml2-2.6.27"
LIBXSLT=“libxslt-1.1.18"
MHASH=“mhash-0.9.4”; MHASH_TAR=”${MHASH}a” # Pests!
ZLIB="zlib-1.2.3"
CURL="curl-7.15.2"
LIBIDN="libidn-0.6.2"
FREETYPE="freetype-2.1.10"
IMAP=“imap-2004g”

Set DISTDIR to somewhere persistent if you plan to muck around with this

script and run it several times! It is where distributions are downloaded.

DISTDIR=${HOME}/dist

Where do you want all this stuff built? Using a local filesystem is best.

Don’t pick a directory that already exists! We clean up after

ourselves at the end!

SRCDIR=${HOME}/source

And where should it be installed? A versioned directory eases upgrades!

INSTALLDIR=${HOME}/${PHP}

A simple name link eases use

ln -s ${INSTALLDIR} php

What PHP features do you want enabled?

PHPFEATURES="–prefix=${INSTALLDIR}
–with-config-file-path=${INSTALLDIR}/etc/php4
–enable-force-cgi-redirect
–with-xml --with-libxml-dir=${INSTALLDIR}
–with-freetype-dir=${INSTALLDIR}
–enable-soap
–with-xsl=${INSTALLDIR}
–with-openssl=/usr
–with-mhash=${INSTALLDIR}
–with-mcrypt=${INSTALLDIR}
–with-zlib-dir=${INSTALLDIR}
–with-jpeg-dir=/usr
–with-png-dir=/usr
–with-gd
–enable-gd-native-ttf
–enable-ftp
–enable-sockets
–enable-wddx
–with-iconv=${INSTALLDIR}
–enable-calendar
–with-curl=${INSTALLDIR}
–enable-mbstring
–enable-mbregex
–enable-allow_url_fopen
–enable-allow_call_time_pass_reference
–enable-display_errors
–enable-enable_dl
–enable-expose_php
–enable-file_uploads
–enable-html_errors
–enable-magic_quotes_gpc
–enable-register_argc_argv
–enable-report_memleaks
–enable-short_open_tag
–enable-register_globals
–enable-safe_mode \

–with-mysql=/usr --with-mysqli
–with-imap=${INSTALLDIR}"

---- end of user-editable bits. Hopefully! ----

Push the install dir’s bin directory into the path

export PATH=${INSTALLDIR}/bin:$PATH

#setup directories
mkdir -p ${SRCDIR}
mkdir -p ${INSTALLDIR}
mkdir -p ${DISTDIR}
cd ${DISTDIR}

Get all the required packages

wget -c http://us3.php.net/distributions/${PHP}.tar.gz
wget -c http://ftp.gnu.org/pub/gnu/libiconv/${LIBICONV}.tar.gz
wget -c http://easynews.dl.sourceforge.net/sourceforge/mcrypt/${LIBMCRYPT}.tar.gz
wget -c ftp://xmlsoft.org/libxml2/${LIBXML2}.tar.gz
wget -c ftp://xmlsoft.org/libxml2/${LIBXSLT}.tar.gz
wget -c http://easynews.dl.sourceforge.net/sourceforge/mhash/${MHASH_TAR}.tar.gz
wget -c http://www.zlib.net/${ZLIB}.tar.gz
wget -c http://curl.haxx.se/download/${CURL}.tar.gz
wget -c ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz
wget -c http://easynews.dl.sourceforge.net/sourceforge/freetype/${FREETYPE}.tar.gz
wget -c ftp://ftp.cac.washington.edu/imap/old/${IMAP}.tar.Z

cd ${SRCDIR}

Unpack them all

tar xzf ${DISTDIR}/${PHP}.tar.gz
tar xzf ${DISTDIR}/${LIBICONV}.tar.gz
tar xzf ${DISTDIR}/${LIBMCRYPT}.tar.gz
tar xzf ${DISTDIR}/${LIBXML2}.tar.gz
tar xzf ${DISTDIR}/${LIBXSLT}.tar.gz
tar xzf ${DISTDIR}/${MHASH_TAR}.tar.gz
tar xzf ${DISTDIR}/${ZLIB}.tar.gz
tar xzf ${DISTDIR}/${CURL}.tar.gz
tar xzf ${DISTDIR}/${LIBIDN}.tar.gz
tar xzf ${DISTDIR}/${FREETYPE}.tar.gz
uncompress -cd ${DISTDIR}/${IMAP}.tar.Z |tar x

Build them in the required order to satisfy dependencies.

#libiconv
cd ${SRCDIR}/${LIBICONV}
./configure --enable-extra-encodings --prefix=${INSTALLDIR}
make
make install

#libxml2
cd ${SRCDIR}/${LIBXML2}
./configure --with-iconv=${INSTALLDIR} --prefix=${INSTALLDIR}
make
make install

#libxslt
cd ${SRCDIR}/${LIBXSLT}
./configure --with-libxml-prefix=${INSTALLDIR} --prefix=${INSTALLDIR}
make
make install

#zlib
cd ${SRCDIR}/${ZLIB}
./configure --shared --prefix=${INSTALLDIR}
make
make install

#libmcrypt
cd ${SRCDIR}/${LIBMCRYPT}
./configure --disable-posix-threads --prefix=${INSTALLDIR}
make
make install

#mhash
cd ${SRCDIR}/${MHASH}
./configure --prefix=${INSTALLDIR}
make
make install

FIXME: For some reason, mincludes.h isn’t copied across

cp ${SRCDIR}/${MHASH}/include/mutils/mincludes.h ${INSTALLDIR}/include/mutils

#libidn
cd ${SRCDIR}/${LIBIDN}
./configure --with-iconv-prefix=${INSTALLDIR} --prefix=${INSTALLDIR}
make
make install

#cURL
cd ${SRCDIR}/${CURL}
./configure --with-ssl=${INSTALLDIR} --with-zlib=${INSTALLDIR}
–with-libidn=${INSTALLDIR} --enable-ipv6 --enable-cookies
–enable-crypto-auth --prefix=${INSTALLDIR}
make
make install

#freetype
cd ${SRCDIR}/${FREETYPE}
./configure --prefix=${INSTALLDIR}
make
make install

imap

cd ${SRCDIR}/${IMAP}
make ldb

Install targets are for wusses!

cp c-client/c-client.a ${INSTALLDIR}/lib/libc-client.a
cp c-client/*.h ${INSTALLDIR}/include

#PHP 4
cd ${SRCDIR}/${PHP}
./configure ${PHPFEATURES}
make
make install

#copy config file
mkdir -p ${INSTALLDIR}/etc/php4
cp ${SRCDIR}/${PHP}/php.ini-dist ${INSTALLDIR}/etc/php4/php.ini

#copy PHP CGI
mkdir -p ${HOME}/${DOMAIN}/cgi-bin
chmod 0755 ${HOME}/${DOMAIN}/cgi-bin
cp ${INSTALLDIR}/bin/php ${HOME}/${DOMAIN}/cgi-bin/php.cgi
echo ---------- INSTALL COMPLETE! ----------


#2

It clearly states on the wiki article that what you are trying to do is “considered advanced”. The fact that you are trying to enable register_globals rather than fixing the script it requires is an indication that you are doing something you probably shouldn’t be doing.

The script provided on the wiki (see link above) is known to work properly; however, you should only attempt to use it if you understand what is happening.


Simon’s website
Save $100 on 1-year plans with promo code [color=#CC0000]SCJESSEY100[/color] (details)


#3

I understand, but I need it for CMS and rss-news. I can’t recode script, because it’s with Zend :frowning:
Why this installation doesn’t works?


#4

There isn’t anything wrong with your install script, as far as I can tell.
To me, it sounds like you aren’t modifying the right php.ini file, or are not modifying it correctly. It’s rather hard to tell, especially with your lack of experience.


#5

What are you mean - right php.ini?
It’s /php-4.4.4/etc/php4/ but I don’t understand - why installation makes another configuration php.ini.


#6

Hi Viktor,

You might find it useful to create a test file called (say) info.php with the following line;

[color=#0000CC]<?php phpinfo(); ?>[/color]

Browsing to this file will show you the current configuration of the PHP install. This way you can see if your php.ini file is being used and also the state of any php settings you are interested in.

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#7

Thanks, but I use it already :slight_smile:
I don’t understand why my conf wasn’t use for my domain…
What is the trouble?


#8

Does phpinfo() confirm that the correct php.ini (the one you are modifying) is being used?

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#9

Yes - it’s my php.ini (because I wrote in install script - allow_url_fopen On), but register_globals and safe_mode is set Off. Why it is? It’s my question…


#10

Well, that is what we are trying to determine. :slight_smile:

Perhaps, but the fact that your other php.ini changes are not being observed suggests that your custom php.ini is not being used.

On the phpinfo() page, exactly what does it show for “Configuration File (php.ini) Path”?

Sorry to repeat myself, but we get quite a few queries on the forum regarding custom PHP installs not working as expected and the problem invariably turns out to be a simple case of the user missing a vital step in the wiki instructions, such as not correctly configuring their .htaccess file etc.

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#11

Path to php.info is /home/.noodge/chitay111/php-4.4.4/etc/php4/php.ini


#12

My .htaccess:

Options ExecCGI
AddHandler php-cgi .php
Action php-cgi /cgi-bin/php.cgi

:wink: It’s ok.


#13

he means put this in a file called “phpinfo.php”:

put that file somehwere on your site accessible to a browser, and browse to it:

http://www.yourdomain.com/phpinfo.php

and read the output…that’s what we need to see.

–rlparker


#14

Thank you for the information. :slight_smile:

I assumed your .htaccess was correct, as the path to php.ini is apparently showing correctly in phpinfo().

Normally, if all I want to do is change a few php.ini settings, I generally just copy the existing DreamHost PHP install across to my domain directory (see this wiki article), as I find building PHP from scratch an overkill for such things.

Having said that, I just used the script you posted above, with my domain inserted at the relevant place of-course, and followed the instructions in this wiki article to build PHP 4.4.4 for one of my domains.

Once this was complete, I modified my .htaccess file, as described in the article to;

[color=#0000CC]AddHandler phpFour .php
Action phpFour /cgi-bin/php.cgi[/color]

I then modified the existing entries in /php-4.4.4/etc/php4/php.ini to register_globals = On and safe_mode = On.

Viewing phpinfo() showed both of these to be On, as expected, so I am not sure why you are having problems.

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#15

http://www.4itay.info/test php.php
look at it!
I change php.ini to safe mode - On, but php info sais - Off.


#16

http://discussion.dreamhost.com/showthreaded.pl?Cat=&Board=forum_troubleshooting&Number=70912&page=0&view=&sb=&o=&vc=1#Post70912


#17

[quote]http://www.4itay.info/test php.php
look at it![/quote]
Yep, it says safe_mode = Off. Although register_globals appears to be On.

Now, look at mine, which was created using your script and the same instructions from the wiki article…

http://www.test.razw.com/test.php

safe_mode is definitely ‘On’ for mine. :wink:

The only thing I can think of, is that somehow you have incorrectly added the safe_mode setting to php.ini

Did you modify the existing safe_mode setting in php.ini, or did you add your own entry? It might be worth going over your php.ini file carefully to make sure you do not have another entry for safe_mode in there.

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#18

Look to my php.ini:
4itay.info/php.ini


#19

I can find nothing wrong with your php.ini file. Let me just confirm (once again) that this is the same php.ini file you have located in /php-4.4.4/etc/php4/php.ini ?

To tell the truth, this problem has me stumped. Your php.ini file looks correct to me, and the output from phpinfo() indicates that /php-4.4.4/etc/php4/php.ini is indeed the php.ini file being used, so it should work. It does for me and I used your script and followed the same instructions as you.

You are welcome to try my php.ini file (linked below), but I can’t really see this making a difference.

http://www.test.razw.com/php.ini

Like I said, it has me stumped. :s

Edit: I just put replaced my php.ini file with yours and safe_mode is still showing as On, strange.

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#20

I stumped too, because php.ini is that located in /php-4.4.4/etc/php4/php.ini…
I reinstall php few times - but always the same.
I’ll install one time!