Skip to content

Instantly share code, notes, and snippets.

@jaywilliams
Last active May 18, 2023 16:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaywilliams/979039 to your computer and use it in GitHub Desktop.
Save jaywilliams/979039 to your computer and use it in GitHub Desktop.
Installing PHP 7.4.33 as CGI on *new* Pair Networks architecture
# Installing PHP 5.3.27 as CGI/FastCGI on the *new* Pair Networks shared
# server architecture
# By Jay Williams <http://myd3.com/>
# Based off of the Pair Users wiki page "Installing PHP5 as cgi" <http://www.pairusers.com/?How%20to%20install%20PHP5>
# Note: Replace "USERNAME" qith your actual server username
# If you're having issues with "make" being quit due to memory usage,
# you can set a lower max on the gcc memory usage, which will slow things
# down but allow you to still compile. Note: If you set or change CFLAGS,
# you will need to re-run the "configure" command(s) for them to take effect.
# setenv CFLAGS "--param ggc-min-expand=0 --param ggc-min-heapsize=4096 -fno-inline"
# Make src directory in home
mkdir ~/src
cd ~/src
# Download, configure, and compile libxml2
wget http://xmlsoft.org/sources/libxml2-2.9.1.tar.gz
tar zxf libxml2-2.9.1.tar.gz
cd libxml2-2.9.1
# Make our local usr directory for libxml2
mkdir -p ~/usr/local
# Note: "--without-python" is needed to prevent permission issues when installing
./configure --prefix=/usr/home/USERNAME/usr/local/ --without-python
make install
make clean
# Download, configure, and compile PHP
cd ~/src
wget http://www.php.net/distributions/php-5.3.27.tar.gz
tar zxf php-5.3.27.tar.gz
cd php-5.3.27
# Make a directory to store our php ini file
mkdir -p ~/phpini/php53
'./configure' '--with-config-file-path=/usr/home/USERNAME/phpini/php53' '--enable-debug=no' '--enable-force-cgi-redirect=yes' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--disable-fileinfo' '--with-libxml-dir=/usr/home/USERNAME/usr/local/' '--enable-soap' '--with-openssl' '--with-curl' '--enable-mbstring'
make
# Use the latest Pair Networks PHP 5.3 php.ini
cp /usr/local/etc/php53/php.ini ~/phpini/php53/php.ini
# Alternatively, you can use the php.ini that you downloaded
# cp php.ini-production ~/phpini/php53/php.ini
# Copy PHP to the cgi-bin directory
cp sapi/cgi/php-cgi ~/public_html/cgi-bin/php53.cgi
strip ~/public_html/cgi-bin/php53.cgi
make clean
# Add this to your .htaccess file:
# Action application/x-httpd-php5cgi /cgi-bin/php53.cgi
# AddType application/x-httpd-php5cgi .php .php5
@jefkin
Copy link

jefkin commented Sep 13, 2012

Of potential note, if you do run into memory limitations and you're using bash/sh (which I think is default?), instead of some csh derivative, then setenv doesn't exist for you,

so you'll want to use, for example:

CFLAGS="--param ggc-min-expand=0 --param ggc-min-heapsize=4096 -fno-inline" bash

however even then I was unable to get even the xml built correctly without reaper reaping me. I've opened a ticket to pair and ... we'll see.

@kmoser
Copy link

kmoser commented Sep 14, 2012

I had no problem with memory limits or being reaped but then I'm on one of Pair's "High Volume" (HV-1) servers.

My application requires PHP 5.2.17, and to enable MySQL support I had to change this:

'--with-mysql=mysqlnd' '--with-mysqli=mysqlnd'

to this:

'--with-mysql' '--with-mysqli'

I merged your configuration options with those that were previously enabled on the PHP build on my server, resulting in the following:

'./configure' '--with-config-file-path=/usr/home/USERNAME/phpini/php52' '--enable-debug=no' '--enable-force-cgi-redirect=yes' '--with-mysql' '--with-mysqli' '--disable-fileinfo' '--with-libxml-dir=/usr/home/USERNAME/usr/local/' '--enable-soap' '--with-openssl' '--with-curl' '--enable-mbstring' '--enable-magic-quotes' '--with-zlib' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--enable-dba' '--with-gdbm' '--with-ndbm' '--with-db4' '--enable-exif' '--with-gd' '--with-jpeg-dir' '--with-freetype-dir' '--with-gettext' '--with-gmp' '--with-mcrypt' '--with-mhash' '--with-iodbc' '--with-pdo-mysql' '--with-pdo-sqlite=/usr/local' '--with-pspell' '--with-xsl' 

@jaywilliams
Copy link
Author

I just updated the script to install PHP 5.3.27 and the latest version of libxml2, as a server configuration change on Pair's side caused my previous binary to no longer work.

@jaywilliams
Copy link
Author

The script has been updated for PHP 7.4.30, on Pair's VPS service. If you want to see the old PHP 5.3 version, view the previous commit:

https://gist.github.com/jaywilliams/979039/d764b58fc842e1b0593749b1005fcef5c8ed2c1d

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