1 min read
First, let's install PHP. Alpine Linux official repositories contain slightly
outdated PHP versions. You can install PHP on Alpine Linux using
apk add --no-cache php7
PHP.earth Alpine repository provides the latest PHP versions.
Adding PHP.earth repository to your Alpine:
apk add --no-cache wget ca-certificates \ && wget -O /etc/apk/keys/phpearth.rsa.pub https://repos.php.earth/alpine/phpearth.rsa.pub \ && echo "https://repos.php.earth/alpine/v3.7" >> /etc/apk/repositories
PHP.earth PHP packages are prefixed with
Installing latest PHP is as simple as:
apk add --no-cache php7.2
apk add --no-cache mongodb
If you're developing PHP applications on your local workstation, PHP also has a useful built-in web server for localhost development. It is not intended to be used for production environments.
Inside your project folder you can run it from the command line using PHP CLI SAPI:
php -S localhost:8000
http://localhost:8000/ in your browser to access it.