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

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.


  • I was struggling with PHP and ncurses. Your tutorial solved my problem, Thank you very much ! :)

  • Jeremy

    It’s so clear, I just spent hours on the official doc. With this post it takes me 5 minutes to install php-ncurses. Thank you very much

  • Laurentiu Badescu

    With a different tutorial I got stuck in the middle but with your help my problem got solved in 1 min. Thank you Tom!

  • Mark R

    Thanks, libncursesw5-dev is exactly what I was looking for.