Install PHP without Apache on Debian

Posted in Linux/Unix/BSD and PHP -

When you go to install PHP on a Debian server, it will attempt to install a whole bunch of Apache packages instead. This is not very useful if you want to install a different web server, or no web server at all.

Dependencies

Run "apt-cache depends php5" to see what dependencies PHP5 has, and you'll get this:

php5
 |Depends: libapache2-mod-php5
 |Depends: libapache2-mod-php5filter
 |Depends: php5-cgi
  Depends: php5-fpm
  Depends: php5-common

Based on the order of the dependencies, if you don't specify one of the lower down ones, it's going to install libapache2-mod-php5 and then all the other Apache stuff too.

Solution

If you don't need the CGI or FPM packages and just need command line PHP, then just install php5-cli, which has no requirement to also install Apache etc:

apt-get install php5-cli

If you do need CGI or FPM support, then add php5-cgi or php5-fpm to your "apt-get install" command before you specify php5, like so:

apt-get install php5-cgi php5

or

apt-get install php5-fpm php5

Example apt-get output

These examples are from a fresh install of Debian 8 Jessie.

apt-get install php5

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 libonig2 libqdbm14 php5-cli
  php5-common php5-json php5-readline ssl-cert
Suggested packages:
  apache2-doc apache2-suexec-pristine apache2-suexec-custom php-pear php5-user-cache openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 libonig2 libqdbm14 php5 php5-cli
  php5-common php5-json php5-readline ssl-cert
0 upgraded, 18 newly installed, 0 to remove and 0 not upgraded.
Need to get 7,307 kB of archives.
After this operation, 27.6 MB of additional disk space will be used.
Do you want to continue? [Y/n]

apt-get install php5-fpm php5

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libapparmor1 libonig2 libqdbm14 php5-cli php5-common php5-json php5-readline
Suggested packages:
  php-pear php5-user-cache
The following NEW packages will be installed:
  libapparmor1 libonig2 libqdbm14 php5 php5-cli php5-common php5-fpm php5-json php5-readline
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 5,407 kB of archives.
After this operation, 20.3 MB of additional disk space will be used.
Do you want to continue? [Y/n]

apt-get install php5-cgi php5

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libonig2 libqdbm14 php5-cli php5-common php5-json php5-readline
Suggested packages:
  php-pear php5-user-cache
The following NEW packages will be installed:
  libonig2 libqdbm14 php5 php5-cgi php5-cli php5-common php5-json php5-readline
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 7,430 kB of archives.
After this operation, 29.2 MB of additional disk space will be used.
Do you want to continue? [Y/n]

apt-get install php5-cli

Note that this is just php5-cli on its own; as soon as you then attempt to install PHP itself

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libonig2 libqdbm14 php5-common php5-json php5-readline
Suggested packages:
  php-pear php5-user-cache
The following NEW packages will be installed:
  libonig2 libqdbm14 php5-cli php5-common php5-json php5-readline
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,152 kB of archives.
After this operation, 11.1 MB of additional disk space will be used.
Do you want to continue? [Y/n]

apt-get install php5-cli php5

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 libonig2 libqdbm14 php5-common
  php5-json php5-readline ssl-cert
Suggested packages:
  apache2-doc apache2-suexec-pristine apache2-suexec-custom php-pear php5-user-cache openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 libonig2 libqdbm14 php5 php5-cli
  php5-common php5-json php5-readline ssl-cert
0 upgraded, 18 newly installed, 0 to remove and 0 not upgraded.
Need to get 7,307 kB of archives.
After this operation, 27.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] 


Related posts:


Comments