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 passionate about technology and building products. A web design business created while attending college slowly evolved into a brick and mortar on Main St. of his small Midwestern hometown. His desire for fame and fortune led to the co-founding of a Y Combinator startup and a life in California.


Hey there! I'm currently writing a book on Microservices which I expect to release in early 2017. If you're interested in getting updates please signup here. More info about the Book
  • 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.