How do you Install PHP5 without installing Apache in ubuntu?

Solution 1:

$ sudo apt-get install php5-cli  

Should do it.

Solution 2:

Install php5 after php5-fpm if you plan to use nginx for example, because php5 needs one of either libapache2-mod-php5, libapache2-mod-php5filter, php5-cgi, or php5-fpm. Apt just picks the first package that satisfies the dependency.

$ sudo apt-get install php5-fpm php5