Skip to content

Instantly share code, notes, and snippets.

@jniltinho
Last active May 19, 2023 15:12
Show Gist options
  • Save jniltinho/959f873a84b72ddd9fca2513a52a6b04 to your computer and use it in GitHub Desktop.
Save jniltinho/959f873a84b72ddd9fca2513a52a6b04 to your computer and use it in GitHub Desktop.
Install PHP 5.5.38 on Ubuntu 16.04 64Bits
#!/bin/bash
### Install PHP 5.5.38 on Ubuntu 16.04 64Bits
### https://www.howtoforge.com/tutorial/how-to-install-php-5-6-on-ubuntu-16-04/
apt-get -y install build-essential libxml2-dev libxslt1-dev
apt-get -y install libfcgi-dev libfcgi0ldbl libjpeg62-dbg libxml2-dev
apt-get -y install libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev
apt-get -y install libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev
apt-get -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.38
mkdir /usr/local/src/php5-build
cd /usr/local/src/php5-build
wget http://br1.php.net/get/php-5.5.38.tar.bz2/from/this/mirror -O php-5.5.38.tar.bz2
tar jxf php-5.5.38.tar.bz2
cd php-5.5.38/
./configure --prefix=/opt/php-5.5.38 --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-openssl --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.38/php.ini-production /opt/php-5.5.38/lib/php.ini
cp /opt/php-5.5.38/etc/php-fpm.conf.default /opt/php-5.5.38/etc/php-fpm.conf
mkdir /opt/php-5.5.38/etc/php-fpm.d
echo "[Unit]
Description=The PHP 5.5.38 FastCGI Process Manager
After=network.target
[Service]
Type=simple
PIDFile=/opt/php-5.5.38/var/run/php-fpm.pid
ExecStart=/opt/php-5.5.38/sbin/php-fpm --nodaemonize --fpm-config /opt/php-5.5.38/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target" >> /lib/systemd/system/php-5.5.38-fpm.service
echo 'zend_extension=opcache.so' >> /opt/php-5.5.38/lib/php.ini
## Mudar ini do PHP
for i in /opt/php-5.5.38/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 = 32M|' $i
sed -i 's|post_max_size = 8M|post_max_size = 32M|' $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 = 'America\/Sao_Paulo'|" $i
done
### Change PHP-FPM Config
sed -i "s|;pid = run/php-fpm.pid|pid = run/php-fpm.pid|" /opt/php-5.5.38/etc/php-fpm.conf
sed -i "s|listen = 127.0.0.1:9000|listen = 127.0.0.1:8989|" /opt/php-5.5.38/etc/php-fpm.conf
sed -i "s|;include=etc/fpm.d/\*.conf|include=/opt/php-5.5.38/etc/php-fpm.d/\*.conf|" /opt/php-5.5.38/etc/php-fpm.conf
systemctl enable php-5.5.38-fpm.service
systemctl daemon-reload
systemctl start php-5.5.38-fpm.service
/opt/php-5.5.38/bin/php-cgi
/opt/php-5.5.38/lib
php-5.5.38-fpm
/opt/php-5.5.38/lib
/opt/php-5.5.38/etc/php-fpm.d
@robinmoisson
Copy link

This is super useful, thank you! 🙏

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