It seems that the only way to do this is to install together an Apache server which is very-very unwanted (in our case).

We just want to utilize the simple built-in web server, as the lucky users of some non-ubuntu OSes (like MS Windows 10) have.

  • What is the purpose? Installing PHP without Apache or installing PHP with something other than Apache? – Yaron Jul 23 '19 at 14:28
  • How comes you think that you can install php only together with Apache. Just sudo apt install php will do. – pLumo Jul 23 '19 at 14:29
  • @Yaron Sorry for not understanding the comment, we just want the same benefit windows users have. – ilias iliadis Jul 23 '19 at 14:30
  • 1
    @pLumo No. It installs Apache also. – ilias iliadis Jul 23 '19 at 14:32
  • 1
    @iliasiliadis Windows and Ubuntu are different entities and operate differently. When you install PHP in Windows, it also configures IIS Web Server to deploy the PHP typically. Are you intending to use straight PHP without any web server, or PHP as a web backend? – Thomas Ward Jul 23 '19 at 14:32

Ubuntu package details says php (php7.2) depends on libapache2-mod-php7.2 OR php7.2-fpm OR php7.2-cgi.

It seems to default to the first package, which itself depends on apache2. But if you install one of the latter first, and php afterwards, apache2 will not be installed.

sudo apt install php-cgi
sudo apt install php

or manually put the resolved dependency:

sudo apt install php php7.2-cgi

Then you can run

php -S localhost:8000
  • Tried this. Seems that cgi is not enough (still installs apache). So I tried both php-fpm and php-cgi which appears to do the trick. – ilias iliadis Jul 28 '19 at 14:57
sudo apt-get --no-install-recommends --dry-run install php 

First simulate. I'm not in ubuntu now. If you are happy you can run

sudo apt-get --no-install-recommends install php
  • This won't work as installing php will install a web server to go with it as it defaults to the Apache module first. OP would have to install either the php-cgi package or php-cli package first before trying to install php - however if they install php-cgi or php-cli they'll get all the PHP common dependencies anyways which does not include a web server. – Thomas Ward Jul 23 '19 at 19:43
  • you a right in bionic is it this way. I was in xenial. – nobody Jul 23 '19 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.