HostOnNet Blog

Install PHP from source for local Development

Looking for Linux Server Admin or WordPress Expert? We can help.

PHP-FPM

Useful PHP Scripts

To Install PHP on Ubuntu Local development machine, install dependencies

sudo apt-get install libcurl4-openssl-dev libjpeg-dev libmcrypt-dev libtidy-dev libxml2-dev libpng12-dev libgd-dev

For PHP 5.6, run


mkdir ~/src
cd ~/src
wget http://in3.php.net/get/php-5.6.30.tar.gz/from/this/mirror -O php-5.6.30.tar.gz
tar xf php-5.6.30.tar.gz
cd ~/src/php-5.6.30
make clean && make distclean
./configure --prefix=$HOME/programs/php-5.6.30 \
--with-mysql \
--with-pdo-mysql \
--enable-cgi \
--with-zlib \
--with-gettext \
--enable-ftp \
--enable-calendar \
--enable-bcmath \
--enable-sockets \
--with-curl \
--with-gd \
--with-jpeg-dir=/usr/local \
--enable-mbstring \
--with-freetype-dir=/usr/local \
--with-mhash=/usr/local --enable-exif \
--with-mcrypt=/usr \
--with-tidy \
--with-openssl \
--enable-zip \
--enable-fpm
make
make install

This will install PHP in folder ~/programs/php-5.6.30

You can run PHP with command

~/programs/php-5.6.30/bin/php

Example

boby@hon-pc-01:~/www/magento (master)$ sudo ~/programs/php-5.6.30/bin/php -S localhost:80
[sudo] password for boby:
PHP 5.6.30 Development Server started at Sat Feb 4 10:09:12 2017
Listening on http://localhost:80
Document root is /home/boby/www/magento
Press Ctrl-C to quit.

Posted in PHP

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.