* Define all modules in a variable

* Move php.ini to /tmp and test for built in modules
* Generate final php.ini by merging the two together and only load needed
  modules from php.ini that are not built in
This commit is contained in:
Scott Ullrich 2008-12-22 05:11:02 +00:00
parent b5bc1a3ae4
commit e83dca8c59

View File

@ -3,6 +3,14 @@
# Set our operating platform
PLATFORM=`cat /etc/platform`
PHPMODULES="pcre bz2 bcmath ctype curl gettext mbstring mhash \
pcntl posix readline session shmop sysvmsg sysvsem sysvshm \
tokenizer xml ldap zlib uploadprogress"
mv /usr/local/etc/php.ini /tmp/
mv /usr/local/lib/php.ini /tmp/
LOADED_MODULES=`php -m | grep -v "\["`
if [ "$PLATFORM" != "cdrom" ]; then
# Populate a dummy php.ini to avoid
# the file being clobbered and the firewall
@ -27,55 +35,28 @@ include_path = ".:/etc/inc:/usr/local/www:/usr/local/captiveportal:/usr/local/pk
uploadprogress.file.filename_template = /tmp/uploadprogress_%s.txt
extension_dir=/usr/local/lib/php/20060613/
; add additional extensions below
; standard PHP extension
extension=pcre.so
extension=bz2.so
extension=bcmath.so
extension=ctype.so
extension=curl.so
extension=gettext.so
extension=mbstring.so
extension=mhash.so
;extension=openssl.so
extension=pcntl.so
extension=posix.so
extension=readline.so
extension=session.so
;extension=simplexml.so
extension=shmop.so
extension=sysvmsg.so
extension=sysvsem.so
extension=sysvshm.so
extension=tokenizer.so
extension=xml.so
extension=ldap.so
extension=zlib.so
extension=uploadprogress.so
; standard PHP extensions currently beeing unused
;extension=json.so
;extension=ncurses.so
;xmlreader.so
;xmlwriter.so
;[xdebug]
;xdebug.remote_enable = On
;xdebug.default_enable = On
;xdebug.remote_mode = On
;xdebug.remote_handler = dbgp
;xdebug.remote_host = 127.0.0.1
;xdebug.remote_port = 17869
;xdebug.idekey = devphp
EOF
# Loop through and generate modules to load.
# Take into account modules built into php.
for EXT in $PHPMODULES; do
SHOULDADD="true"
for LM in $LOADED_MODULES; do
if [ "$EXT" = "$LM" ]; then
SHOULDADD="false"
fi
done
if [ "$SHOULDADD" = "true" ]; then
echo "extension=${EXT}.so" >> /usr/local/lib/php.ini
fi
done
RAM=`sysctl hw.realmem | awk '{print $2/1000000}' | awk -F '.' '{print $1}'`
export RAM
if [ $RAM -gt 96 ]; then
cat >>/usr/local/lib/php.ini <<EOF
extension=apc.so
apc.enabled="1"
apc.enable_cli="1"
apc.shm_size="25"