Skip to content

Instantly share code, notes, and snippets.

@kheuser
Last active May 22, 2024 20:16
Show Gist options
  • Save kheuser/b35e0b6ffa0d386658fd1c3da129ce50 to your computer and use it in GitHub Desktop.
Save kheuser/b35e0b6ffa0d386658fd1c3da129ce50 to your computer and use it in GitHub Desktop.
Install php5.5.9 on Ubuntu 20.04
apt -y install build-essential libxml2-dev libxslt1-dev
apt -y install libfcgi-dev libfcgi0ldbl libjpeg62-dbg libxml2-dev
apt -y install libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev
apt -y install libbz2-dev libcurl4-openssl-dev libjpeg-dev
apt -y install libfreetype6-dev libkrb5-dev libpq-dev libicu-dev
ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a
mkdir /opt/php-5.5.9
mkdir /usr/local/src/php5-build
cd /usr/local/src/php5-build
wget http://us2.php.net/distributions/php-5.5.9.tar.bz2
tar -xvf php-5.5.9.tar.bz2
cd /usr/include
ln -s x86_64-linux-gnu/curl
cd /usr/local/src/php6-build/php-5.5.9
./configure --prefix=/opt/php-5.5.9 --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring \
--with-libxml-dir=/usr --enable-soap --enable-intl --enable-calendar --with-curl --with-mcrypt --with-zlib \
--with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets \
--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash \
--enable-zip --with-pcre-regex --with-mysql --with-pdo-mysql --with-mysqli --with-jpeg-dir=/usr --with-png-dir=/usr \
--enable-gd-native-ttf --with-fpm-user=www-data --with-fpm-group=www-data \
--with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-imap --with-imap-ssl --with-gettext --with-xmlrpc --with-xsl \
--with-kerberos --enable-fpm
make
make install
cp /usr/local/src/php5-build/php-5.5.9/php.ini-production /opt/php-5.5.9/lib/php.ini
cp /opt/php-5.5.9/etc/php-fpm.conf.default /opt/php-5.5.9/etc/php-fpm.conf
mkdir /opt/php-5.5.9/etc/php-fpm.d
echo "[Unit]
Description=The PHP 5.5.9 FastCGI Process Manager
After=network.target
[Service]
Type=simple
PIDFile=/opt/php-5.5.9/var/run/php-fpm.pid
ExecStart=/opt/php-5.5.9/sbin/php-fpm --nodaemonize --fpm-config /opt/php-5.5.9/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target" >> /lib/systemd/system/php-5.5.9-fpm.service
echo 'zend_extension=opcache.so' >> /opt/php-5.5.9/lib/php.ini
for i in /opt/php-5.5.9/lib/php.ini;do
sed -i 's|max_execution_time = 30|max_execution_time = 120|' $i
sed -i 's|upload_max_filesize = 2M|upload_max_filesize = 512M|' $i
sed -i 's|post_max_size = 8M|post_max_size = 128M|' $i
sed -i 's|error_reporting = E_ALL & ~E_DEPRECATED|error_reporting = E_ERROR|' $i
sed -i 's|short_open_tag = Off|short_open_tag = On|' $i
sed -i "s|;date.timezone =|date.timezone = 'Europe\/Budapest'|" $i
done
### Change PHP-FPM Config
sed -i "s|;pid = run/php-fpm.pid|pid = run/php-fpm.pid|" /opt/php-5.5.9/etc/php-fpm.conf
sed -i "s|listen = 127.0.0.1:9000|listen = 127.0.0.1:8989|" /opt/php-5.5.9/etc/php-fpm.conf
sed -i "s|;include=etc/fpm.d/\*.conf|include=/opt/php-5.5.9/etc/php-fpm.d/\*.conf|" /opt/php-5.5.9/etc/php-fpm.conf
systemctl enable php-5.5.9-fpm.service
systemctl daemon-reload
systemctl start php-5.5.9-fpm.service
a2enmod proxy_fcgi
systemctl restart apache2
mkdir /var/lib/php5-fpm
echo "[default]
listen = /var/lib/php5-fpm/default.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
user = www-data
group = www-data
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 5
pm.max_requests = 0
chdir = /
env[HOSTNAME] = $HOSTNAME
env[TMP] = /var/www/tmp
env[TMPDIR] = /var/www/tmp
env[TEMP] = /var/www/tmp
env[PATH] = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
php_admin_value[open_basedir] = /var/www/html:/var/www/tmp:/tmp
php_admin_value[session.save_path] = /var/www/tmp
php_admin_value[upload_tmp_dir] = /var/www/tmp" >> /opt/php-5.5.9/etc/php-fpm.d/default.conf
### PHP support for vhost (/etc/apache2/sites-enabled/000-default.conf)
<VirtualHost *:80>
...
<IfModule mod_proxy_fcgi.c>
<Directory /var/www/html>
<FilesMatch "\.php[345]?$">
SetHandler "proxy:unix:/var/lib/php5-fpm/default.sock|fcgi://localhost"
</FilesMatch>
</Directory>
</IfModule>
...
</VirtualHost>
systemctl restart php-5.5.9-fpm
systemctl restart apache2
@scottw-finao
Copy link

scottw-finao commented May 22, 2024

On 22.04 it seems to puke up quite a bit on the intl package. I was able to get some success using --disable-intl, but do you have any suggestions for getting the intl to work on newer systems? It looks like a lot of the problems tie in over changes in libicu-dev

I also needed libltdl-dev

@kheuser
Copy link
Author

kheuser commented May 22, 2024

On 22.04 it seems to puke up quite a bit on the intl package. I was able to get some success using --disable-intl, but do you have any suggestions for getting the intl to work on newer systems? It looks like a lot of the problems tie in over changes in libicu-dev

I also needed libltdl-dev

I was never able to get php5.0 to work with 22.04. In the case above when I was working on this, I did try. I believe there was just too many deprecations and breaking changes between 20.04 and 22.04 that made it too incompatible. I do remember libicu-dev being a big issue when I was working on this.

What I ended up doing was going with 20.04, using that until we could get our app updated to php7.2. Then we were able to get 7.2 installed on 22.04 without too much issue.

@scottw-finao
Copy link

scottw-finao commented May 22, 2024

i got it working by disabling the intl package, and was getting at least closer with some poking but it's dying on scope related issues at present. Either it needs some refactoring in the intl stuff that uses icu-dev or perhaps needs to be compiled with an older version of libicu installed that still includes icu-config

@scottw-finao
Copy link

I'm wondering if maybe anyone may have built a work-around replacement for icu-config. I ran into a similar issue with freetype and it's freetype-config that was deprecated in favor of pkg-config. That led me to this script:

kaisersource/freetype-config

Perhaps something similar could be done with icu -- I may look more closely at this later and give it a shot based on the free-type script:

How to use ICU

@kheuser
Copy link
Author

kheuser commented May 22, 2024

@scottw-finao It is probable that someone has figured out the icu issue. If you do find something, could you comment it here? That would be awesome!

@scottw-finao
Copy link

will do - in the meantime I'm playing with a version without the intl to see if it can be used on an old codebase we have without complaining.

@scottw-finao
Copy link

go figure, it dies on --enable-openssl also - it seems to want older versions with known vulnerabilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment