How to install PHP? (For Command Line use only)

PHP installation is required for command line use only


A. Windows 

Follow instructions at noted here 

  1. Download PHP 7.2.28
  2. Unzip and rename the folder to PHP
  3. Move PHP folder to C:/
  4. Add new Environment Variables for PHP
  5. Restart computer
  6. Test PHP on terminal/command prompt

B. Mac OS

Recent versions of Mac OS already ship with php7.2.x+


C. Linux

Install with root privileges 

On Debian/Ubuntu see article here

# Only the following items are needed for foldershare client
apt-get install php7.2-cli php7.2-curl php7.2-mbstring

On CentOS

yum -y install centos-release-scl.noarch
yum search php72-
yum install rh-php72-php-cli.x86_64
yum install rh-php72-php-mbstring.x86_64

Building minimal PHP from source

Download latest PHP7.2.x then unzip and build as follows 

# Fetch php7.2.28 source
curl -o php-7.2.28.tar.gz -L http://php.net/get/php-7.2.28.tar.gz/from/this/mirror

# untar php source
tar xzf php-7.2.28.tar.gz

cd php-7.2.28

# Configure php for minimal build that we need for the FolderShare client
# Optionally add --prefix=/path/to/install
./configure --disable-all --disable-cgi --enable-cli --enable-filter --enable-json --enable-mbstring --with-curl --with-readline 

# build
make
# make install #if you added prefix

# Add environment path to find php
export PATH=`pwd`/sapi/cli:$PATH" #change this path if you added prefix

# Check if php is now in environment path
php -v

# Consider adding the php path in your shell profile (e.g. basic)

Add environment path

After installing PHP, add php to your environment path for e.g. append the following to your ~/.bashrc

export PATH="/full/path/to/php:$PATH"