PHP setup for command line usage

Submitted by seedadmin on Wed, 02/27/2019 - 12:14

The FolderShare command line client requires PHP with curl,  json & mbstring extensions. Check if your system already has PHP7 installed (Recent versions of Linux & Mac OS already have PHP7 installed).

# On terminal issue the following command
php -v


If PHP is not available use one of the following two methods to install php7 on your system


1. Building minimal PHP from source on linux

Download latest PHP7.x then unzip and build as follows 

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

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

cd php-7.2.10

# Configure php for minimal build that we need for the FolderShare client
# Optionally add --prefix=/path/to/install
./configure --disable-all --enable-cli --enable-mbstring --with-curl  --disable-cgi --enable-json --enable-filter --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)

2. Install PHP with root privileges

apt-get install php7-cli php7-curl php7-mbstring php7-cli