How to install PHP on Visual Studio Online / Codespaces ← (PHP, MySQL)

Constant error for any and all versions of PHP - no installation candidate. I've ran apt-get update and upgrade / dist-upgrade and added the sury repo on a new codespace.

vsonline:~/workspace$ sudo apt-get install php
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package php is a virtual package provided by:
  php7.4 7.4.6-1+0~20200514.17+debian9~1.gbp0f509e [Not candidate version]
  php7.3 7.3.18-1+0~20200515.59+debian9~1.gbp12fa4f [Not candidate version]
  php7.2 7.2.31-1+0~20200514.41+debian9~1.gbpe2a56b [Not candidate version]
  php7.1 7.1.33-16+0~20200514.38+debian9~1.gbp1e5820 [Not candidate version]
  php7.0 7.0.33-29+0~20200514.36+debian9~1.gbp126f6f [Not candidate version]
  php5.6 5.6.40-29+0~20200514.35+debian9~1.gbpcc49a4 [Not candidate version]
  php7.3 7.3.14-1~deb10u1 [Not candidate version]
  uwsgi-plugin-php 2.0.17.1+8+0.0.3+b3 [Not candidate version]
  php7.3 7.3.11-1~deb10u1 [Not candidate version]
  php7.0 7.0.33-0+deb9u7 [Not candidate version]
  php7.0 7.0.33-0+deb9u6 [Not candidate version]

E: Package 'php' has no installation candidate

Answer



Solution:

I'm having the same headache, but I decided to do the manual installation

use:

wget https://www.php.net/distributions/php-7.4.9.tar.gz
#Or the version of your preference

Unpack and install

tar zxf php-x.x.x
cd ../php-x.x.x
./configure --enable-fpm --with-mysqli
make
sudo make install

Obtain and move configuration files to their correct locations

cp php.ini-development /usr/local/php/php.ini
cp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.conf
cp sapi/fpm/php-fpm /usr/local/bin

Source: official documentation Links download php

Or if you prefer to use Docker I recommend the laradock that makes the job much easier. I ended up using it, Doc is very easy Laradock DOC

Source