Installation and Setup of Grav (Flat-File CMS)
Grav does not require a database. Minimum requirements: PHP 7.3.6+ (recommended 8.1+), extensions mbstring, curl, ctype, dom, gd, json, xml, zip. Apache or Nginx.
Installation
# Option 1: Direct download
curl -L https://getgrav.org/download/core/grav-admin/latest -o grav-admin.zip
unzip grav-admin.zip -d /var/www/mysite
cd /var/www/mysite
# Option 2: Via Composer
composer create-project getgrav/grav /var/www/mysite
# Set permissions
find . -type f | xargs chmod 664
find . -type d | xargs chmod 775
find . -type d -name cache | xargs chmod 777
find . -type d -name logs | xargs chmod 777
find . -type d -name images | xargs chmod 777
find . -type d -name assets | xargs chmod 777
Nginx Configuration
server {
listen 80;
server_name mysite.com;
root /var/www/mysite;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Protect system directories
location ~ ^/(\.git|cache|logs|backup|bin|system|vendor|\.env) {
return 403;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
system.yaml Configuration
# user/config/system.yaml
home:
alias: /home
pages:
theme: my-theme
markdown:
extra: true # enable Markdown Extra (tables, footnotes)
auto_line_breaks: false
cache:
enabled: true
driver: auto
lifetime: 604800
debugger:
enabled: false
errors:
display: 0
log: true
languages:
supported: [ru, en]
include_default_lang: false
translations: true
site.yaml Configuration
# user/config/site.yaml
title: My Site
author:
name: Company
email: [email protected]
metadata:
description: Site description
taxonomies: [category, tag]
summary:
enabled: true
size: 300
GPM — Package Manager
# Update package list
bin/gpm index
# Install plugin
bin/gpm install form login admin sitemap feed
# Update everything
bin/gpm update
# Update Grav core
bin/gpm selfupgrade
# List installed packages
bin/gpm list
Create Admin User
# Via CLI (without web installer)
bin/plugin login newuser \
--user=admin \
--password=Admin123! \
[email protected] \
--name="Admin Name" \
--admin=true
Environment Configuration Customization
# user/config/env/production/system.yaml — production overrides
cache:
enabled: true
driver: redis
redis:
socket: '/var/run/redis/redis.sock'
debugger:
enabled: false
# user/config/env/development/system.yaml
cache:
enabled: false
debugger:
enabled: true
shutdown:
close_connection: true
Environment switching via GRAV_ENVIRONMENT=production variable or via setup.php:
// setup.php in root
$environment = getenv('GRAV_ENVIRONMENT') ?: 'production';
define('GRAV_ENVIRONMENT', $environment);







