Advertisement
Guest User

php 5.3 on ubuntu 18.04

a guest
Sep 16th, 2019
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 25.95 KB | None | 0 0
  1.  apt-get install -y libcurl4 curl libcurl4-openssl-dev libc-client2007e libc-client2007e-dev libssl1.1 libssl-dev \
  2.   libsnmp-dev comerr-dev krb5-multidev libgssrpc4 libkadm5clnt-mit11 libkadm5srv-mit11 libkdb5-9 libpam0g-dev libpci-dev \
  3.   libsensors4-dev libudev-dev libwrap0-dev zlib1g-dev
  4.  
  5.  #php5.3 libraries/tools for compile
  6.  apt-get install -y build-essential autoconf automake autotools-dev re2c cmake cmake-data libjsoncpp1 librhash0
  7.  apt-get install -y apache2-dev libbz2-dev libssl1.0.0 bzip2-doc libapr1-dev libaprutil1-dev libexpat1-dev \
  8.   libldap2-dev libsctp-dev libsctp1 uuid-dev
  9.  apt-get install -y libedit-dev libenchant-dev libfreetype6 libfreetype6-dev enchant hunspell-en-us libbsd-dev \
  10.   libenchant1c2a libglib2.0-bin libglib2.0-dev libglib2.0-dev-bin libhunspell-1.6-0 libncurses5-dev libpng-dev \
  11.   libpng-tools libtinfo-dev pkg-config python3-distutils
  12.  apt-get install -y libgeoip-dev libgmp3-dev libgmp-dev unixodbc-dev libaspell-dev libpspell-dev \
  13.   geoip-bin libgmpxx4ldbl odbcinst odbcinst1debian2
  14.  apt-get install -y libkrb5-dev libltdl7 libltdl-dev libmcrypt4
  15.  apt-get install -y libmagickwand-dev \
  16.   gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-rsvg-2.0 javascript-common libcairo-gobject2 libcairo-script-interpreter2 \
  17.   libcairo2-dev libdjvulibre-dev libdjvulibre-text libdjvulibre21 libexif-dev libexif-doc libexif12 libfontconfig1-dev \
  18.   libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgdk-pixbuf2.0-dev libice-dev libice6 libilmbase-dev \
  19.   libilmbase12 libjbig-dev libjpeg-turbo8-dev libjs-jquery liblcms2-dev liblqr-1-0-dev \
  20.   liblzma-dev libmagickcore-6-arch-config libmagickcore-6-headers libmagickcore-6.q16-3-extra libmagickcore-6.q16-dev \
  21.   libmagickwand-6-headers libmagickwand-6.q16-dev libopenexr-dev libopenexr22 libpixman-1-dev libpthread-stubs0-dev \
  22.   librsvg2-2 librsvg2-common librsvg2-dev libsm-dev libsm6 libtiff-dev libtiff5-dev libtiffxx5 libwmf-dev libwmf0.2-7 \
  23.   libx11-dev libx11-doc libxau-dev libxcb-render0-dev libxcb-shm0-dev libxcb1-dev libxdmcp-dev libxext-dev libxml2-dev \
  24.   libxrender-dev libxt-dev libxt6 x11-common x11proto-core-dev x11proto-dev x11proto-xext-dev xorg-sgml-doctools \
  25.   xtrans-dev
  26.  
  27.  apt-get install -y libmcrypt-dev libmhash-dev libmhash2 libpam0g-dev libpng-dev html2text
  28.  apt-get install -y libpq-dev libreadline-dev libsasl2-dev libsnmp-dev libsqlite3-dev
  29.  apt-get install -y libtidy-dev libxml2 libxml2-dev libxslt1-dev libz3-dev libzip4 gettext libz3-4
  30.  apt-get install -y xfonts-base xfonts-75dpi fonts-liberation libfontenc1 xfonts-encodings xfonts-utils libxpm4 libxpm-dev
  31.  apt-get install -y librecode-dev librecode0 librecode-dev librecode0
  32.  
  33.  # 18.04 only, otherwise you are missing icu-config made avaialble via icu-devtools
  34.  apt-get install -y --allow-downgrades libicu-dev=60.2* icu-devtools=60.2* gir1.2-harfbuzz-0.0 libgraphite2-dev libharfbuzz-dev libharfbuzz-gobject0 libharfbuzz-icu0 libicu-le-hb-dev libicu-le-hb0 libiculx60
  35.  
  36.  apt-get install -y libtool-bin # 18.04 only?
  37.  
  38.  #install different versions of gcc - is easier to compile php with gcc 5.5.0
  39.  apt-get install -y gcc-5
  40.  rm /usr/bin/gcc
  41.  update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 55
  42.  update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 74
  43.  update-alternatives --set gcc /usr/bin/gcc-5
  44.  
  45.  mkdir -p /usr/include/x86_64-linux-gnu/curl/include
  46.  ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/x86_64-linux-gnu/curl/include/curl
  47.  
  48.  cd /tmp
  49.  wget https://www.openssl.org/source/openssl-1.0.2s.tar.gz
  50.  tar -xzf openssl-1.0.2s.tar.gz
  51.  cp -r openssl-1.0.2s /usr/src
  52.  cd /usr/src/openssl-1.0.2s
  53.  ./config --prefix=/usr/local --openssldir=/usr/local/openssl shared
  54.  make -j$(nproc) 2>&1 | tee build.make.openssl.log
  55.  make install
  56.  make clean
  57.  
  58.  #make custom paths for php compile
  59.  mkdir -p /usr/local/openssl/include
  60.  ln -s /usr/local/include/openssl /usr/local/openssl/include/openssl
  61.  mkdir -p /usr/local/openssl/lib
  62.  #ln -s /usr/src/openssl-1.0.2s /usr/local/openssl/lib/x86_64-linux-gnu
  63.  ln -s /usr/local/lib /usr/local/lib/x86_64-linux-gnu
  64.  
  65.  cd /tmp
  66.  wget https://museum.php.net/php5/php-5.3.29.tar.bz2
  67.  tar -xjf php-5.3.29.tar.bz2
  68.  cp -r php-5.3.29 /usr/src/
  69.  
  70.  export APACHE_RUN_USER=httpservice
  71.  export APACHE_RUN_GROUP=httpusers
  72.  export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid
  73.  export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
  74.  export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
  75.  export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
  76.  export EXTENSION_DIR=/usr/lib/php/5.3/20090626
  77.  
  78.  cd /usr/src/php-5.3.29
  79.  
  80.  # the following modules need to be compiled after, as they require openssl 1.1 vs the main php program which requires openssl 1.0
  81.  # cannot seem to force compile c-client /w openssl 1.0 to make imap work
  82.  # probably can build later after compiling base php and switching system package versions back to openssl 1.1 default packages
  83.  # snmp must be skipped at main compile for same reason
  84.  # --with-imap=shared,/usr/include
  85.  # --with-snmp
  86.  # --enable-intl
  87.  # causes apache php module segfaults if compiling with main php program
  88.  # --enable-ftp
  89.  
  90.  #note: curl seems to compile fine as part of the main php with --with-curl=shared,/usr/include/x86_64-linux-gnu/curl
  91.  #but i have decided to compile it below instead, as it appears to be able to compile with openssl 1.1 that way despite main program using 1.0
  92.  
  93.  # for phar to avoid this error message:
  94.  # PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
  95.  # run pear install PHP_Archive-alpha once pear is working
  96.  
  97.  #note: cannot include zlib (shared or static) if using --enable-mysqlnd=shared
  98.  #either that, or --enablemysqlnd=shared is not possible while using it for mysql/mysqli
  99.  
  100.  ./configure --prefix=/usr/lib/php/5.3 --with-pear=/usr/lib/php/5.3/pear --with-config-file-path=/etc/php/5.3/apache2 --with-config-file-scan-dir=/etc/php/5.3/apache2/conf.d \
  101.   --with-apxs2=/usr/bin/apxs2 --disable-embed --disable-fpm --disable-cgi --disable-cli \
  102.   --with-libdir=lib/x86_64-linux-gnu --disable-gcov \
  103.   --enable-inline-optimization --enable-maintainer-zts --enable-short-tags --enable-zend-multibyte --enable-libgcc \
  104.   --with-openssl=shared,/usr/local --with-zlib=/usr \
  105.   --enable-pdo --with-pgsql=shared,/usr/bin --with-pdo-pgsql=shared,/usr/bin \
  106.   --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-pdo-mysql=mysqlnd \
  107.   --with-sqlite3=shared,/usr --with-pdo-sqlite=sqlite3 --with-unixODBC=shared,/usr --with-pdo-odbc=unixODBC,/usr \
  108.   --disable-ctype --disable-dom --disable-fileinfo --disable-filter --disable-hash --disable-json \
  109.   --disable-posix --disable-simplexml --disable-tokenizer --disable-xmlreader --disable-xmlwriter \
  110.   --build=x86_64-pc-linux-gnu | tee build.configure.apache2.min.log
  111.  
  112.  make -j$(nproc) 2>&1 | tee build.make.apache2.min.log
  113.  make install
  114.  libtool --finish /usr/src/php-5.3.29/libs
  115.  make clean
  116.  #apparently need --disable-mysqlnd-compression-support if building --with-zlib=shared,/usr so we remove shared
  117.  ./configure --prefix=/usr/lib/php/5.3 --with-pear=/usr/lib/php/5.3/pear --with-config-file-path=/etc/php/5.3/cgi --with-config-file-scan-dir=/etc/php/5.3/cgi/conf.d \
  118.   --disable-embed --disable-fpm --enable-cgi --disable-cli \
  119.   --with-libdir=lib/x86_64-linux-gnu --disable-gcov \
  120.   --enable-inline-optimization --enable-maintainer-zts --enable-short-tags --enable-zend-multibyte --enable-libgcc \
  121.   --with-openssl=shared,/usr/local --with-zlib=/usr \
  122.   --enable-pdo --with-pgsql=shared,/usr/bin --with-pdo-pgsql=shared,/usr/bin \
  123.   --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-pdo-mysql=mysqlnd \
  124.   --with-sqlite3=shared,/usr --with-pdo-sqlite=sqlite3 --with-unixODBC=shared,/usr --with-pdo-odbc=unixODBC,/usr \
  125.   --disable-ctype --disable-dom --disable-fileinfo --disable-filter --disable-hash --disable-json \
  126.   --disable-posix --disable-simplexml --disable-tokenizer --disable-xmlreader --disable-xmlwriter \
  127.   --build=x86_64-pc-linux-gnu | tee build.configure.cgi.min.log
  128.  
  129.  make -j$(nproc) 2>&1 | tee build.make.cgi.min.log
  130.  make install
  131.  make clean
  132.  #need to remove --disable-xml or add --without-pear here, so probably best to not use --disable-xml in any SAPIs
  133.  ./configure --prefix=/usr/lib/php/5.3 --with-pear=/usr/lib/php/5.3/pear --with-config-file-path=/etc/php/5.3/cli --with-config-file-scan-dir=/etc/php/5.3/cli/conf.d \
  134.   --disable-embed --disable-fpm --disable-cgi --enable-cli \
  135.   --with-libdir=lib/x86_64-linux-gnu --disable-gcov \
  136.   --enable-inline-optimization --enable-maintainer-zts --enable-short-tags --enable-zend-multibyte --enable-libgcc \
  137.   --with-openssl=shared,/usr/local --with-zlib=/usr \
  138.   --enable-pdo --with-pgsql=shared,/usr/bin --with-pdo-pgsql=shared,/usr/bin \
  139.   --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-pdo-mysql=mysqlnd \
  140.   --with-sqlite3=shared,/usr --with-pdo-sqlite=sqlite3 --with-unixODBC=shared,/usr --with-pdo-odbc=unixODBC,/usr \
  141.   --disable-ctype --disable-dom --disable-fileinfo --disable-filter --disable-hash --disable-json \
  142.   --disable-posix --disable-simplexml --disable-tokenizer --disable-xmlreader --disable-xmlwriter \
  143.   --build=x86_64-pc-linux-gnu | tee build.configure.cli.min.log
  144.  
  145.  make -j$(nproc) 2>&1 | tee build.make.cli.min.log
  146.  #skip all subsequent calls to make test from asking if you want to send a failure report to the PHP team
  147.  export NO_INTERACTION=true
  148.  make test | tee build.maketest.cli.min.log
  149.  make install
  150.  make clean
  151.  
  152.  #note: If you end up going back and recompiling PHP for any of the above SAPIs,
  153.  #apparently you need to do CLI again so that it is the last one done, as it seems to affect phpize environment variables
  154.  #and then you start getting this error any time you try to use the make test command when building a module:
  155.  #ERROR: Cannot run tests without CLI sapi.
  156.  
  157.  update-alternatives --install /usr/bin/php php /usr/lib/php/5.3/bin/php 53
  158.  update-alternatives --install /usr/bin/php-cgi php-cgi /usr/lib/php/5.3/bin/php-cgi 53
  159.  update-alternatives --install /usr/bin/php-config php-config /usr/lib/php/5.3/bin/php-config 53
  160.  update-alternatives --install /usr/bin/phar phar /usr/lib/php/5.3/bin/phar 53
  161.  update-alternatives --install /usr/bin/phar.phar phar.phar /usr/lib/php/5.3/bin/phar.phar 53
  162.  update-alternatives --install /usr/bin/phpize phpize /usr/lib/php/5.3/bin/phpize 53
  163.  
  164.  update-alternatives --set php /usr/lib/php/5.3/bin/php
  165.  update-alternatives --set php-cgi /usr/lib/php/5.3/bin/php-cgi
  166.  update-alternatives --set php-config /usr/lib/php/5.3/bin/php-config
  167.  update-alternatives --set phar /usr/lib/php/5.3/bin/phar
  168.  update-alternatives --set phar.phar /usr/lib/php/5.3/bin/phar.phar
  169.  update-alternatives --set phpize /usr/lib/php/5.3/bin/phpize
  170.  
  171.  mkdir /usr/lib/php/5.3/sapi
  172.  touch /usr/lib/php/5.3/sapi/apache2 /usr/lib/php/5.3/sapi/cgi /usr/lib/php/5.3/sapi/cli
  173.  ln -s /usr/lib/php/5.3/bin/phpize /usr/bin/phpize5.3
  174.  #ln -s /usr/lib/php/5.3/bin/phpconfig /usr/bin/phpconfig5.3
  175.  ln -s /usr/lib/php/5.3/bin/php-config /usr/bin/php-config5.3
  176.  ln -s /usr/lib/php/5.3/bin/php-cgi /usr/bin/php-cgi5.3
  177.  mkdir -p /etc/php/5.3/mods-available /etc/php/5.3/cli/conf.d /etc/php/5.3/cgi/conf.d /etc/php/5.3/apache2/conf.d
  178.  
  179.  echo extension=openssl.so > /etc/php/5.3/mods-available/openssl.ini
  180.  phpenmod -v 5.3 -s ALL openssl
  181.  
  182.  #first fix /usr/share/php/PEAR/Installer.php and Downloader.php for php 5.3 by finding "...()[...]"
  183.  #and manually editing to replace with $bob = ...(); and $bob[...]
  184.  #example: error_get_last()["message"] becomes $bob["message"] with $bob=error_get_last(); added a line above
  185.  #or scp from another server with native php 5.3
  186.  #scp /usr/share/php/PEAR/Installer.php web18git1.aplus:/usr/share/php/PEAR/Installer.php
  187.  #scp /usr/share/php/PEAR/Downloader.php web18git1.aplus:/usr/share/php/PEAR/
  188.  
  189.  pear update-channels
  190.  pecl update-channels
  191.  pear upgrade --force
  192.  #pecl upgrade --force
  193.  
  194.  #install PHP_Archive and APC from PECL, we will enable them later:
  195.  printf "\n" | pear install PHP_Archive-alpha
  196.  printf "\n" | pecl install apc
  197.  
  198.  
  199.  #modules which can be built without any configuration customizations
  200.  
  201.  #create temporary functions to make compiling/testing the simpler modules easy
  202.  
  203.  function makephpmod(){
  204.    cd /usr/src/php-5.3.29/ext/$1
  205.    phpize
  206.    ./configure
  207.    make -j$(nproc) 2>&1 | tee build.make.$1.log
  208.    make test | tee build.maketest.$1.log
  209.    make install
  210.    make clean
  211.  }
  212.  
  213.  function maketestphpmod(){
  214.    cd /usr/src/php-5.3.29/ext/$1
  215.    phpize
  216.    ./configure
  217.    make -j$(nproc) 2>&1 | tee build.make.$1.log
  218.    make test | tee build.maketest.$1.log
  219.    make clean
  220.  }
  221.  
  222.  #link the GMP header file so that GMP can compile as expected in Ubuntu
  223.  ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
  224.  
  225.  #compile all the simple PHP modules
  226.  for i in bcmath bz2 calendar ctype dba dom exif fileinfo filter gettext gmp hash json mbstring mcrypt pcntl posix pspell readline ; do makephpmod $i; done
  227.  for i in recode shmop simplexml snmp soap sockets sysvmsg sysvsem sysvshm tidy tokenizer xmlreader xmlrpc xmlwriter xsl wddx zip ; do makephpmod $i; done
  228.  # for i in ftp ; do maketestphpmod $i; done
  229.  
  230.  #commands which sometimes fix errors with old packages, more relevant if compiling with gcc > 5.5.0:
  231.  #unneeded in our case
  232.  #phpize
  233.  #aclocal
  234.  #libtoolize --force
  235.  #autoheader
  236.  #autoconf
  237.  #autoreconf --force --install
  238.  
  239.  
  240.  
  241.  #modules which must be built with configuration customizations or which fail no tests
  242.  
  243.  
  244.  cd /usr/src/php-5.3.29/ext/curl
  245.  phpize
  246.  ./configure --with-curl=shared,/usr/include/x86_64-linux-gnu/curl | tee build.configure.curl.log
  247.  make -j$(nproc) 2>&1 | tee build.make.curl.log
  248.  make test | tee build.maketest.curl.log
  249.  make install
  250.  make clean
  251.  
  252.  cd /usr/src/php-5.3.29/ext/ftp
  253.  phpize
  254.  ./configure --enable-ftp --with-libdir=lib/x86_64-linux-gnu --with-openssl-dir=/usr
  255.  make -j$(nproc) 2>&1 | tee build.make.ftp.log
  256.  make test | tee build.maketest.ftp.log
  257.  make install
  258.  make clean
  259.  
  260.  apt-get install -y quilt
  261.  
  262.  cd /tmp
  263.  wget http://archive.ubuntu.com/ubuntu/pool/main/libj/libjpeg6b/libjpeg6b_6b2.orig.tar.gz
  264.  tar -xf libjpeg6b_6b2.orig.tar.gz
  265.  wget http://archive.ubuntu.com/ubuntu/pool/main/libj/libjpeg6b/libjpeg6b_6b2-2.debian.tar.xz
  266.  tar -xf libjpeg6b_6b2-2.debian.tar.xz
  267.  mv debian jpeg-6b2/
  268.  cp -r jpeg-6b2 /usr/src/
  269.  cd /usr/src/jpeg-6b2
  270.  export QUILT_PATCHES=debian/patches
  271.  quilt push -a
  272.  ./configure --prefix=/usr/local
  273.  make -j$(nproc)
  274.  make test
  275.  make install
  276.  
  277.  cd /tmp
  278.  wget http://archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng_1.2.54.orig.tar.xz
  279.  #wget http://archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng_1.2.54-1ubuntu1.debian.tar.xz
  280.  wget http://archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng_1.2.54-1ubuntu1.1.debian.tar.xz
  281.  tar -xf libpng_1.2.54.orig.tar.xz
  282.  tar -xf libpng_1.2.54-1ubuntu1.1.debian.tar.xz
  283.  mv debian libpng-1.2.54/
  284.  cp -r libpng-1.2.54 /usr/src/
  285.  cd /usr/src/libpng-1.2.54/
  286.  export QUILT_PATCHES=debian/patches
  287.  quilt push -a
  288.  ./configure --prefix=/usr/local/include
  289.  #if using gss > 5.5.0
  290.  autoreconf -fi
  291.  make -j$(nproc)
  292.  #make test
  293.  make install
  294.  make clean
  295.  cd /tmp
  296.  apt-get source libxpm-dev libx11-dev
  297.  cp -r /tmp/libxpm-3.5.12 /usr/src/
  298.  cp -r /tmp/libx11-1.6.4 /usr/src/
  299.  cd /usr/src/libxpm-3.5.12
  300.  ./configure --prefix=/usr/local
  301.  make -j$(nproc)
  302.  #make test
  303.  make install
  304.  make clean
  305.  cd /usr/src/libx11-1.6.4
  306.  ./configure --prefix=/usr/local
  307.  make -j$(nproc)
  308.  #make test
  309.  make install
  310.  make clean
  311.  cd /tmp
  312.  #wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/libgd2/2.0.36~rc1~dfsg-6ubuntu2.1/libgd2_2.0.36~rc1~dfsg.orig.tar.gz
  313.  wget http://archive.ubuntu.com/ubuntu/pool/main/libg/libgd2/libgd2_2.0.36~rc1~dfsg.orig.tar.gz
  314.  #wget http://archive.ubuntu.com/ubuntu/pool/main/libg/libgd2/libgd2_2.0.36~rc1~dfsg-6ubuntu2.debian.tar.gz
  315.  wget http://archive.ubuntu.com/ubuntu/pool/main/libg/libgd2/libgd2_2.0.36~rc1~dfsg-6ubuntu2.4.debian.tar.gz
  316.  tar -xf libgd2_2.0.36~rc1~dfsg.orig.tar.gz
  317.  #tar -xf libgd2_2.0.36~rc1~dfsg-6ubuntu2.debian.tar.gz
  318.  tar -xf libgd2_2.0.36~rc1~dfsg-6ubuntu2.4.debian.tar.gz
  319.  mv debian libgd2_2.0.36~rc1~dfsg.orig
  320.  cp -r libgd2_2.0.36~rc1~dfsg.orig /usr/src/
  321.  cd /usr/src/libgd2_2.0.36~rc1~dfsg.orig
  322.  export QUILT_PATCHES=debian/patches
  323.  quilt push -a
  324.  #if using gcc 5.5.0
  325.  autoreconf -fi
  326.  ./configure --prefix=/usr/local/lib/libgd --with-jpeg=/usr/local --with-png=/usr/local --with-xpm=/usr/local --libdir=local/lib | tee build.configure.log
  327.  make -j$(nproc)
  328.  #make test
  329.  make install
  330.  make clean
  331.  rm -r /usr/local/lib/libgd/php
  332.  mkdir -p /usr/local/lib/libgd/php
  333.  cp /usr/local/lib/libgd/include/* /usr/local/lib/libgd/php
  334.  cp /usr/local/lib/libgd/lib/* /usr/local/lib/libgd/php
  335.  #ln -s /usr/lib/x86_64-linux-gnu/libXpm.so /usr/local/lib/
  336.  #ln -s /usr/include/X11/xpm.h /usr/local/include/
  337.  cd /usr/src/php-5.3.29/ext/gd
  338.  phpize
  339.  #--with-xpm-dir=/usr/local
  340.  #./configure --with-gd=shared,/usr/local/lib/libgd/php --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-xpm-dir=/usr \
  341.  #--with-zlib-dir=/usr --with-freetype-dir=/usr --enable-gd-native-ttf --with-libdir=lib/x86_64-linux-gnu \
  342.  #--build=x86_64-pc-linux-gnu | tee build.configure.log
  343.  
  344.  #manually merge this fix from https://github.com/php/php-src/pull/1507/files to resolve
  345.  #GD issue with apache2 SAPI causing phpinfo() crashes with "undefined symbol: gdJpegGetVersionString"
  346.  #more info: https://github.com/php/php-src/pull/1507 and https://github.com/oerdnj/deb.sury.org/issues/111
  347.  #first back up file just in case
  348.  cp libgd/gd_compat.c gd_compat.c.backup
  349.  sed -i 's/#include "php_config.h"/#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif/' libgd/gd_compat.c
  350.  
  351.  #may need to run these as well, as configure apparently ignored --with-libdir on one of my tests with gcc 5.5.0:
  352.  ln -s /usr/local/lib/libjpeg.so.62.0.0 /usr/lib/x86_64-linux-gnu/libjpeg.so.62.0.0
  353.  ln -s /usr/local/lib/libjpeg.so.62 /usr/lib/x86_64-linux-gnu/libjpeg.so.62
  354.  #you will know if this is the case if you proceed and make test result skips every test and says the following:
  355.  #Warning: PHP Startup: Unable to load dynamic library '/usr/src/php-5.3.29/ext/gd/modules/gd.so' - libjpeg.so.62: cannot open shared object file: No such file or directory in Unknown on line 0
  356.  
  357.  ./configure --with-gd=shared,/usr/local/lib/libgd/php --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local \
  358.   --with-zlib-dir=/usr --with-freetype-dir=/usr --enable-gd-native-ttf --with-libdir=local/lib | tee build.configure.log
  359.  make -j$(nproc) 2>&1 | tee build.make.gd.log
  360.  make test | tee build.maketest.gd.log
  361.  make install
  362.  make clean
  363.  
  364.  #comes built into main php compile, should probably skip
  365.  #cd /usr/src/php-5.3.29/ext/iconv
  366.  #phpize
  367.  #./configure
  368.  #make -j$(nproc) 2>&1 | tee build.make.iconv.log
  369.  #make test | tee build.maketest.iconv.log
  370.  #make install
  371.  #make clean
  372.  
  373.  cd /usr/src/php-5.3.29/ext/imap
  374.  phpize
  375.  ./configure --with-kerberos --with-imap-ssl
  376.  make -j$(nproc) 2>&1 | tee build.make.imap.log
  377.  make test | tee build.maketest.imap.log
  378.  make install
  379.  make clean
  380.  
  381.  #builds with many test errors, but we can install from pecl instead, possibly requiring a big downgrade to libicu55 first
  382.  #cd /usr/src/php-5.3.29/ext/intl
  383.  #phpize
  384.  #./configure
  385.  #make -j$(nproc) 2>&1 | tee build.make.intl.log
  386.  #make test | tee build.maketest.intl.log
  387.  #make install
  388.  #make clean
  389.  
  390.  cd /usr/src/php-5.3.29/ext/ldap
  391.  phpize
  392.  ./configure --with-ldap=/usr --with-ldap-sasl --with-libdir=lib/x86_64-linux-gnu
  393.  make -j$(nproc) 2>&1 | tee build.make.ldap.log
  394.  make test | tee build.maketest.ldap.log
  395.  make install
  396.  make clean
  397.  
  398.  cd /usr/src/php-5.3.29/ext/mssql
  399.  apt-get install -y freetds-common freetds-dev libct4 libsybdb5
  400.  phpize
  401.  ./configure --with-libdir=lib/x86_64-linux-gnu
  402.  make -j$(nproc) 2>&1 | tee build.make.mssql.log
  403.  make test | tee build.maketest.mssql.log
  404.  make install
  405.  make clean
  406.  
  407.  #make test says "warning: #warning Readline module will *NEVER* be thread-safe"
  408.  cd /usr/src/php-5.3.29/ext/readline
  409.  phpize
  410.  ./configure
  411.  make -j$(nproc) 2>&1 | tee build.make.readline.log
  412.  make test | tee build.maketest.readline.log
  413.  make clean
  414.  
  415.  #cd /usr/src/php-5.3.29/ext/xmlrpc
  416.  #if using gcc > 5.5.0, you probably have to compile this with these flags set first, otherwise process is normal (then unset them)
  417.  #export CC="gcc"
  418.  #export CFLAGS="-O2 -fno-delete-null-pointer-checks -finline-functions -fomit-frame-pointer"
  419.  #phpize
  420.  #./configure
  421.  #make -j$(nproc) 2>&1 | tee build.make.xmlrpc.log
  422.  #make test | tee build.maketest.xmlrpc.log
  423.  #make install
  424.  #make clean
  425.  #unset CC
  426.  #unset CFLAGS
  427.  
  428.  #old version of imagick can be used if manually downloaded from pecl
  429.  #pecl command will think none are available
  430.  cd /tmp
  431.  wget wget https://pecl.php.net/get/imagick-3.4.0RC1.tgz
  432.  tar -xf imagick-3.4.0RC1.tgz
  433.  cp -r imagick-3.4.0RC1 /usr/src/
  434.  cd /usr/src/imagick-3.4.0RC1
  435.  phpize
  436.  ./configure
  437.  make -j$(nproc) 2>&1 | tee build.make.imagick.log
  438.  make test | tee build.maketest.imagick.log
  439.  make install
  440.  make clean
  441.  #echo "extension=imagick.so" > /etc/php/5.3/mods-available/imagick.ini
  442.  #phpenmod -v 5.3 -s ALL imagick
  443.  
  444.  cd /tmp
  445.  wget https://xdebug.org/files/xdebug-2.2.7.tgz
  446.  tar -xf xdebug-2.2.7.tgz
  447.  cp -r xdebug-2.2.7 /usr/src/
  448.  cd /usr/src/xdebug-2.2.7
  449.  phpize
  450.  ./configure --with-php-config=/usr/lib/php/5.3/bin/php-config
  451.  make -j$(nproc) 2>&1 | tee build.make.xdebug.log
  452.  make test | tee build.maketest.xdebug.log
  453.  make install
  454.  
  455.  #getting pecl install intl to work:
  456.  
  457.  #if you get compile errors like this:
  458.  #error: ‘UChar’ does not name a type
  459.  #then you may need to remove libicu and all dependencies, forcibly download libicu55 and icu-devtools version 55
  460.  #compile intl, then update back to 60.2 and reinstall all removed dependencies later
  461.  #general process:
  462.  
  463.  apt-get remove -y icu-devtools libharfbuzz-dev libicu-dev libicu-le-hb-dev libmagickcore-6.q16-dev libmagickwand-6.q16-dev libmagickwand-dev libxml2-dev libxslt1-dev
  464.  cd /tmp
  465.  wget http://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.4_amd64.deb
  466.  dpkg -i libicu55_55.1-7ubuntu0.4_amd64.deb
  467.  wget http://archive.ubuntu.com/ubuntu/pool/main/i/icu/icu-devtools_55.1-7ubuntu0.4_amd64.deb
  468.  dpkg -i icu-devtools_55.1-7ubuntu0.4_amd64.deb
  469.  wget http://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu-dev_55.1-7ubuntu0.4_amd64.deb
  470.  dpkg -i libicu-dev_55.1-7ubuntu0.4_amd64.deb
  471.  pecl install intl
  472.  #re-upgrade packages afterward
  473.  apt-get install -y --allow-downgrades icu-devtools=60.2* libharfbuzz-dev libicu-dev=60.2* libicu-le-hb-dev libmagickcore-6.q16-dev libmagickwand-6.q16-dev libmagickwand-dev libxml2-dev libxslt1-dev
  474.  
  475.  
  476.  #module compilation complete, proceed to installing modules and next steps:
  477.  
  478.  
  479.  cd /usr/lib/php/5.3/20090626
  480.  for i in $(ls -1 *.so) ; do echo "extension=${i}" > /etc/php/5.3/mods-available/$(echo ${i} | sed 's/.so//g ').ini ; phpenmod -v 5.3 -s ALL $(echo ${i} | sed 's/.so//g '); done
  481.  #comes with main php
  482.  #phpdismod -v 5.3 -s ALL iconv
  483.  phpdismod -v 5.3 -s ALL apc
  484.  #probably only makes sense in apache2
  485.  phpenmod -v 5.3 -s apache2 apc
  486.  #fix xdebug:
  487.  echo "zend_extension=/usr/lib/php/5.3/20090626/xdebug.so" > /etc/php/5.3/mods-available/xdebug.ini
  488.  echo "xdebug.overload_var_dump = 0" >> /etc/php/5.3/mods-available/xdebug.ini
  489.  #optional params for APC:
  490.  echo "apc.stat = On" >> /etc/php/5.3/mods-available/apc.ini
  491.  echo "apc.shm_size = 32M" >> /etc/php/5.3/mods-available/apc.ini
  492.  echo "apc.apc.gc_ttl = 900" >> /etc/php/5.3/mods-available/apc.ini
  493.  chmod 644 /etc/php/5.3/mods-available/*
  494.  
  495.  cd /tmp
  496.  wget --no-check-certificate https://download.suhosin.org/suhosin-0.9.37.1.tar.gz
  497.  tar -xzf suhosin-0.9.37.1.tar.gz
  498.  cp -r suhosin-0.9.37.1 /usr/src/
  499.  cd /usr/src/suhosin-0.9.37.1
  500.  phpize
  501.  ./configure
  502.  make -j$(nproc) 2>&1 | tee build.make.suhosin.log
  503.  make test | tee build.maketest.suhosin.log
  504.  make install
  505.  #loosen some of the default restrictions which are a bit tight, esp for bad/old code
  506.  echo "extension=suhosin.so" > /etc/php/5.3/mods-available/suhosin.ini
  507.  echo "suhosin.post.max_value_length = 1048560" >> /etc/php/5.3/mods-available/suhosin.ini
  508.  echo "suhosin.simulation = Off" >> /etc/php/5.3/mods-available/suhosin.ini
  509.  echo "suhosin.post.max_array_depth = 500" >> /etc/php/5.3/mods-available/suhosin.ini
  510.  echo "suhosin.post.max_array_index_length = 500" >> /etc/php/5.3/mods-available/suhosin.ini
  511.  echo "suhosin.post.max_name_length = 500" >> /etc/php/5.3/mods-available/suhosin.ini
  512.  echo "suhosin.post.max_totalname_length = 500" >> /etc/php/5.3/mods-available/suhosin.ini
  513.  echo "suhosin.post.max_value_length = 65000" >> /etc/php/5.3/mods-available/suhosin.ini
  514.  echo "suhosin.post.disallow_nul = On" >> /etc/php/5.3/mods-available/suhosin.ini
  515.  echo "suhosin.upload.max_uploads = 128" >> /etc/php/5.3/mods-available/suhosin.ini
  516.  echo "suhosin.request.max_varname_length = 500" >> /etc/php/5.3/mods-available/suhosin.ini
  517.  echo "suhosin.get.max_value_length = 1024" >> /etc/php/5.3/mods-available/suhosin.ini
  518.  
  519.  phpenmod -v 5.3 -s apache2 suhosin
  520.  
  521.  #check which modules have failed tests or where all tests were skipped - may indicates serious problems such as a wrong version or missing library:
  522.  fgrep 'Tests failed' /usr/src/php-5.3.29/ext/*/build.maketest.*.log | fgrep -v 'Tests failed    :    0'
  523.  fgrep '100.0%' /usr/src/php-5.3.29/ext/*/build.maketest.*.log | grep skipped
  524.  
  525.  #a2enmod php5 has already been run after compiling apache2 SAPI module
  526.  a2dismod php5.6
  527.  cp /etc/apache2/mods-available/php5.6.conf /etc/apache2/mods-available/php5.conf
  528.  service apache2 stop
  529.  service apache2 start
  530.  tail /var/log/apache2/error.log
  531.  
  532.  
  533.  #done!
  534.  
  535.  
  536.  #compare vs. ubuntu 12.04 php5-* pkg list:
  537.  # adodb
  538.  # curl
  539.  # exactimage
  540.  # ffmpeg
  541.  # gd
  542.  # geoip
  543.  # gmp
  544.  # imagick
  545.  # imap
  546.  # ldap
  547.  # intl
  548.  # mapscript
  549.  # mcrypt
  550.  # odbc
  551.  # pgsql
  552.  # ps
  553.  # pspell
  554.  # sasl
  555.  # snmp
  556.  # sqlite
  557.  # svn
  558.  # sybase
  559.  # tidy
  560.  # xdebug
  561.  # xmlrpc
  562.  # xsl
  563.  #
  564.  # auth-pam
  565.  # idn
  566.  # json
  567.  # librdf
  568.  # uuid
  569.  # mhash
  570.  # ming
  571.  # mssql
  572.  # recode
  573.  # remctl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement