Setting Up Apache with PHP
Installing Apache + PHP
Enable the repositories:
cat > /etc/apk/repositories << EOF http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/main http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/community EOF apk update
Add the main packages with the command:
php"$phpverx"-apache2 will be "5" or "7" depending of the alpine version installed, since alpine 3.9 there's only the php7 packages.
Move to the directory where your site will reside:
And create an index.php file to test if everything is ok:
Add the following lines in the file:
<?php phpinfo(); ?>
That done, let us start apache2 web server:
Now access: http://<ip_address> and if everything is ok you will see the PHP info page.
Finally let us set up apache2 to start on operating system startup:
Now you can create your PHP site and host in this directory.
This is the easiest way to setup Apache with PHP support, but it's the most inefficient (resource wise) setup, please refer to Apache with php-fpm