Posted by & filed under PHP, Web Server.

I recently had the task of installing the PHP PECL extension ncurses on my Ubuntu 10.04 (Desktop) machine. PECL is a repository manager for PHP extensions. Ncurses is a tool for doing all sorts of awesome command line terminal stuff, such as colors, building windows, updating part of the screen instead of the entire screen, etc.

I already had PHP5 installed, which provided the PECL and PEAR utilities. Unfortunately, phpize (which is required by PECL to install either some or all extensions) was not provided. Execute the two following commands to get PECL happy and install ncurses.

sudo apt-get install php5-dev
sudo apt-get install ncurses-dev
sudo apt-get install libncursesw5-dev
sudo pecl install ncurses
sudo nano /etc/php5/cli/php.iniĀ  # paste "" somewhere

Once this is done you should be ready to roll with PHP ncurses! You can put the following into a file named test.php and run it to make sure it works:

nano test.php # paste contents which follow
chmod u+x ./test.php

Here is the PHP code to paste into nano (right click paste if you’re in a GUI) (once it’s in there, Ctrl+O, Enter, Ctrl+x):


Good luck! Let me know if you have any trouble.

Thomas Hunter II

Support Thomas on Patreon. Thomas is the author of Advanced Microservices and a prolific public speaker with a passion for reducing complex problems into simple language and diagrams. His career includes working at Fortune 50's in the Midwest, co-founding a successful startup, and everything in between.