Build and Install latest PHP cURL extenstion on RunCloud

There is bug in libcurl 7.68 so using 7.73 or higher is recommended.

We are gonna build latest cURL on Ubuntu 16.04 but this should work fine for 18.04 and 20.04.

## Create path for custom builds
## To avoid conflicts do not use system paths 
sudo mkdir /usr/myownbuilds

## Create a temporary directory
## And do all stuff there
mkdir ~/mytmpdir

## nghttp2 is required by cURL to use http/2 protocol
## so we need to build it first
cd ~/mytmpdir
VERSION=1.42.0
wget -qO- https://github.com/nghttp2/nghttp2/releases/download/v${VERSION}/nghttp2-${VERSION}.tar.gz | tar -xz
cd nghttp2-${VERSION}
autoreconf -i
automake
autoconf
./configure --prefix=/usr/myownbuilds
make -j$(nproc)
sudo make install

## OpenSSL required by cURL to use https
## so we need to build it too.
cd ~/mytmpdir
VERSION=1.1.1h
wget -qO- https://www.openssl.org/source/openssl-${VERSION}.tar.gz | tar -xz
cd openssl-${VERSION}
./config --prefix=/usr/myownbuilds --openssldir=/usr/myownbuilds shared zlib
make -j$(nproc)
sudo make install

## Brotli required by cURL
## so we need to build it too.
cd ~/mytmpdir
git clone --depth=1 https://github.com/google/brotli.git
cd brotli
./bootstrap
./configure --prefix=/usr/myownbuilds
make -j$(nproc)
sudo make install

## Add pkgconfig to the PKG_CONFIG_PATH
## This will tell pkgconfig to look libs also in this directory
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/myownbuilds/lib/pkgconfig

## Now build cURL, change version number.
## Make sure /usr/myownbuilds/lib/pkgconfig is on PKG_CONFIG_PATH
cd ~/mytmpdir
VERSION=7.73.0
wget -qO- https://curl.se/download/curl-${VERSION}.tar.gz | tar -xz
cd curl-${VERSION}
./configure \
    --prefix=/usr/myownbuilds \
    --with-nghttp2=/usr/myownbuilds \
    --with-{ssl,brotli} \
    --with-{libssh,libssh2}
make -j$(nproc)
sudo make install

Now cURL and its libraries are successfully built. Now we need to build php-curl extension.

## Make sure /usr/myownbuilds/lib/pkgconfig is on PKG_CONFIG_PATH
## Other wise build will fail.
cd ~/mytmpdir
VERSION=7.4.12
wget -qO- https://www.php.net/distributions/php-${VERSION}.tar.gz | tar -xz
cd php-${VERSION}/ext/curl

PHPRC_VERSION="php74rc"
/RunCloud/Packages/$PHPRC_VERSION/bin/phpize
./configure --with-php-config=/RunCloud/Packages/$PHPRC_VERSION/bin/php-config
make -j$(nproc)

## curl.so should be here
cd modules

## move curl.so
sudo mkdir /usr/myownbuilds/$PHPRC_VERSION-ext
sudo mv curl.so /usr/myownbuilds/$PHPRC_VERSION-ext

## Modify extension path on curl.ini
sudo nano /etc/$PHPRC_VERSION/conf.d/curl.ini
extension=/usr/myownbuilds/php74rc-ext/curl.so

## Verify it's working.
## Check using: php -i | grep "curl info" -i
## Once verfied, reload fpm.
sudo systemctl reload $PHPRC_VERSION-fpm