Grav can be easily installed with docker. Besides docker's installation, that is behind our scopes, here are the steps:

Let's assume grav will be installed in /opt/grav

cd /opt && sudo mkdir grav \
&& cd grav \
&& sudo wget https://getgrav.org/download/core/grav-admin/latest -O grav-admin.zip \
&& sudo unzip grav-admin.zip \
&& sudo mv grav-admin grav \
&& sudo rm grav-admin.zip 
&& sudo chown www-data:www-data grav -R 

Let's then create the Dockerfile file based on php apache official image:

sudo su - 
cat << EOF > Dockerfile
FROM php:8.0-apache
RUN apt-get update
RUN apt-get install -y libzip-dev libpng-dev libjpeg-dev
RUN docker-php-ext-configure gd --with-jpeg
RUN docker-php-ext-install zip gd
RUN a2enmod rewrite
EOF

Same thing with the docker-compose.yaml file (change the 8080 port in case you want to make it listen on another):

cat << EOF > docker-compose.yaml
version: '3'
services:
  webserver:
    build: .
    ports:
      - "8080:80"
    volumes:
      - ./grav:/var/www/html
    environment:
      - PHP_MAX_EXECUTION_TIME=300
    command: >
      bash -c "apache2-foreground"
EOF

Said that, to start grav:

docker compose up -d 

And point your browser to http://[ip_of_dockerhost]:8080

Next Post