Home » Php » Ubuntu Server Installing PHP 7 WITHOUT Apache

Ubuntu Server Installing PHP 7 WITHOUT Apache

Posted by: admin April 23, 2020 Leave a comment

Questions:

I’m trying to get my server re-setup as a Lemp stack

The issue I am now running into is installing PHP 7 without Apache, since nGinx will be my webserver.

So, I’ve added ppa:ondrej/php. ran apt-get update, and tried to install just php7.0 via apt-get install php7.0

--nodeps flag does not work, as I am on Ubuntu 15.10

And I am presented with:

The following extra packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.0 libapr1
  libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 libqdbm14
  php-common php-readline php7.0 php7.0-cli php7.0-common php7.0-json
  php7.0-opcache php7.0-readline
Suggested packages:
  apache2-doc apache2-suexec-pristine apache2-suexec-custom php-pear
  php-user-cache
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.0 libapr1
  libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 libqdbm14
  php php-common php-readline php7.0 php7.0-cli php7.0-common php7.0-json
  php7.0-opcache php7.0-readline

I do not want apache anywhere near my server, so how can I install php7 without it? Short of compiling from source (as this makes it difficult at best to keep it updated)

How to&Answers:

If you just request php7.0, it’ll install Apache as default. Do apt-get install php7.0-fpm and it’ll install as FPM instead, leaving something like nginx up to you.

Answer:

Use the command:

sudo apt install php7.2 php7.2-common php7.2-cli php7.2-fpm

It will require the php7.2 dependencies in strict mode (WITHOUT apache2).

Answer:

On Ubuntu 18.04 I managed to do this successfully with:

sudo apt-get install php7.2-cli