You can run the code examples by using either PHP's built-in web server or Docker containers.
- Install both PHP 5.6 and PHP 7 on a VM
- Create a symlink /usr/bin/php5 to the php 5.6 install
- Create a symlink /usr/bin/php7 to the php 7.0 install
- Upload the code examples
- Open 2 terminal windows and cd to the code examples in both
- In the 1st: php5 -S ip_address:5656
- In the 2nd: php7 -S ip_address:7070
Prerequisites :
To run the containers :
$ php composer.phar install
$ php vendor/bin/linuxforcomposer.phar docker:run start
To stop the containers :
$ php vendor/bin/linuxforcomposer.phar docker:run stop
NOTE: On Windows, please use the Linux for Composer PHAR file in the 'vendor/linuxforphp/linuxforcomposer/bin' folder and replace the '${PWD}' environment variable with the full path to this working directory in the 'volumes' section of the 'linuxforcomposer.json' file (ex. '/c/Users/php7_examples:/srv/www').
- Open a new tab
- Go to ip_address:5656
- Open a new tab
- Go to ip_address:7070
In addition, if you are using the Docker containers :
- Open a new tab
- Go to ip_address:7171
- Open a new tab
- Go to ip_address:7272
- Now you can demo the results of the same code in both PHP 5.x and PHP 7.x (PHP 7.1 and 7.2 if you are using Docker)
firewall-cmd --zone=public --add-port=5656/tcp --permanent
firewall-cmd --zone=public --add-port=7070/tcp --permanent
firewall-cmd --reload
- find line numbers:
iptables -L INPUT --line-numberss
- insert the rule after a certain line number (i.e. 2)
iptables -I INPUT 2 -p tcp -m state --state NEW -m tcp --dport 5656 -j ACCEPT
iptables -I INPUT 2 -p tcp -m state --state NEW -m tcp --dport 7070 -j ACCEPT
- save the new rules
service iptables save
- Download the target version
- cd to that directory
- Run these commands (assumes Linux, not logged in as root)
$./configure --with-pdo-mysql=/usr --enable-calendar --with-curl=/usr/include/curl --with-openssl --with-gettext=/usr --with-mhash=DIR --enable-intl --enable-mbstring --with-mcrypt=/usr --with-mysql-sock=/var/run/mysqld.sock --with-pdo-mysql=/usr --enable-zip --with-openssl=/usr --with-libxml-dir=/usr --with-libdir=/lib/x86_64-linux-gnu --enable-sockets --enable-libxml --enable-soap --with-gd --with-jpeg-dir=/usr --with-webp-dir=/usr --with-xpm-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-freetype-dir=/usr --enable-gd-native-ttf
$ make
$ make test
$ sudo make install
By default, make install
will install all the files in /usr/local/bin
, /usr/local/lib
etc.
You can specify an installation prefix other than /usr/local
using --prefix
, for instance
--prefix=$HOME
Libraries needed (given the "./configure" string above)
- sudo apt-get install libxml2-dev
- sudo apt-get install libssl-dev
- sudo apt-get install libcurl4-openssl-dev
- sudo apt-get install libwebp-dev
- sudo apt-get install libjpeg-dev
- sudo apt-get install libpng-dev
- sudo apt-get install libxpm-dev
- sudo apt-get install libfreetype6-dev
- sudo apt-get install libmcrypt-dev
- sudo apt-get install libmysqlclient-dev
- sudo apt-get install libvpx-dev
- Assumes MySQL has been installed
See: https://crybit.com/20-common-php-compilation-errors-and-fix-unix/