Installing PHP Extensions on

Bruno Skvorc
Bruno Skvorc

Inspired by a comment on my previous article, I realized Nitrous was still a bit too complicated to customize properly. In this tutorial, we’ll glide through installing cURL and Phalcon on a PHP box.

cURL is a bundled PHP library that is often installed alongside PHP. It’s included in the PHP source, but during installation a flag needs to be passed to PHP in order for it to include and activate cURL. Phalcon is a high-performance C-based MVC framework. We’ve written about it before. Phalcon is a third party extension, and thus not bundled with PHP.

Getting started

To get started with a PHP box, see my previous article. After the initial short procedure (you can skip the whole Composer and Laravel business), you’ll have PHP installed, but without the extensions we need. To verify cURL is missing, try adding the following content to your index.php file in the default www folder:

    echo "Curl is" . ((function_exists('curl_version')) ? "" : " not") . " installed";

Previewing in the browser on the default port 3000 will show that cURL is, obviously, not installed. It is, however, installed system-wide. You can verify this by just checking the version in the console, and getting the following output:

Thus, we only need the PHP extension to be able to use it. Usually, PHP’s cURL extension is installed with PHP with the flag --with-curl[=DIR] while executing the configure command. In other scenarios, it’s easily installable by calling something as simple as sudo apt-get install php5-curl. However, in our case, neither of these appraches will work. The former cannot be achieved because PHP is already installed and the source code is no longer on the machine, and the latter is unavailable to us because we don’t have sudo access.

What we’ll be doing next is building cURL from PHP’s source code, and adding it into our configuration manually.

Downloading PHP’s source code

If we check the PHP version on at this moment, it’s 5.5.8. The latest PHP version is, however, 5.5.9. To avoid any potential incompatibility issues, we’ll clone the exact version we’re building the extension for.

Browse through the old archives and pick the appropriate version. When you find a link you like, do the following (Note that the tools directory should exist if you followed along with the last article; if not, create it):

cd /home/action/.tools

Uncompress the archive by running tar -xjvf is you downloaded the .bz2 file, or tar -xzvf if you downloaded .gz. This will produce a folder with the same name as the archive. We now have PHP’s source code for version 5.5.8.

Building the cURL extension

It’s important to note that this procedure can be applied to any extension bundled with PHP that hasn’t been installed by default. We’re using cURL in this article due to the comment on the previous one, and due to the fact that it’s a popular extension. Enter the extensions folder of the PHP source code.

cd php-5.5.8/ext

All the available bundled extensions reside here, with their full source code. CD into the curl folder and run the procedure below:

cd curl
./configure --with-curl
make install

This builds the extension from source, places the file into the modules subfolder, and copies it to the PHP extensions folder in /home/action/.parts/packages/php5/5.5.8/lib/extensions/no-debug-zts-20121212/.

Activating the cURL extension

To activate the extension, all we need to do is add a line to our php.ini and restart the web server. Activate showing hidden files in the file browser panel, and go to ~/.parts/etc/php5. There, edit the php.ini file: find the string “Module Settings”, then above it, add the line

Save the file, and run parts restart apache2 in the console. You might get an error saying something like

(98)Address already in use: AH00072: make_sock: could not bind to address
no listening sockets available, shutting down
AH00015: Unable to open logs
parts: ERROR: "/home/action/.parts/packages/apache2/2.4.7/bin/apachectl start" failed                            

If you do, just run the same command again and it should work.

Now try to preview the index.php file from before on port 3000 again, and if all went well, the message should say cURL is now installed.

You can make extra sure by changing the contents back to phpinfo() and looking for the cURL section:

Downloading and building Phalcon

As per instructions on their website, we clone the repo and then build the extension.

cd ~/.tools
git clone --depth=1 git://
cd cphalcon/build

In the last step, we don’t need sudo because the action account Nitrous boxes use is quite elevated, having permissions beyond those of a typical user account.

As soon as the compilation completes, Phalcon’s build script automatically copies the file into the PHP extensions folder. You can then follow the same procedure as above to activate the extension. Enter php.ini and add into the mix, as shown below:

Re-checking the phpinfo() output from before after running parts restart apache2 should show Phalcon as installed:


In this tutorial, we’ve demonstrated the ease of installing custom PHP extensions on This procedure can be applied to installing PHP extensions anywhere – you don’t need to rebuild the entire PHP source code just to add a bundled extension into the mix. In time, as popularity rises, Nitrous may add a simpler way to pull in extensions – perhaps even through “parts”, their package manager – but for now, we’re stuck with this manual process. While tedious, it certainly isn’t difficult.

Have you played around on Nitrous yet? If so, what have you built? If not, what’s stopping you? Let us know in the comments below!