User Tools

Site Tools


servers:windows:nginx:grav

Information

Screenshots

Notes

  • 2024/06/29: Grav is particularly annoying about needing a svg logo instead of being able to render it plaintext, and I can't figure out how to customize footer text seemingly without a theme override

Prerequisites

Dependencies

Git

  • Git from the command line and also from 3rd-party software

Composer

Download Source

git clone --branch "develop" --depth "1" --recurse-submodules "https://github.com/getgrav/grav.git" "C:\www\main"
explorer "C:\www\main"

Environment

PHP

notepad++ "%SystemDrive%\www\php\main-php.ini"
[PHP]
extension_dir = ".\ext"
extension="curl"
extension="gd"
extension="mbstring"
extension="openssl"
extension="zip"

[Date]
date.timezone = "America/New_York"

Composer

  • :?: This expects php in PATH which Composer's installer does, but unsure how PHP updates will be handled
CD "%SystemDrive%\www\main\" && php -c "%SystemDrive%\www\php\main-php.ini" "%ProgramData%\ComposerSetup\bin\composer.phar" install --no-dev -o

Grav CLI

  • :?: This expects php in PATH which Composer's installer does, but unsure how PHP updates will be handled
CD "%SystemDrive%\www\main\" && php "%SystemDrive%\www\main\bin\grav" install

nginx + PHP-CGI Configuration

PHP-CGI

notepad++ "%SystemDrive%\www\nginx-default.d\main.conf"
# PHP-CGI
    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9001;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
        fastcgi_intercept_errors on;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTPS on;
    }

Server Block

notepad++ "%SystemDrive%\www\nginx-vhosts.d\main.conf"
server {
    listen "443" "ssl";
    http2 "on";
    server_name "realmofespionage.xyz";
    root "C:/www/main";
    index "index.php";

    include C:/www/nginx-default.d/main.conf;
    include C:/www/nginx-default.d/headers.conf;

    client_max_body_size "30M";

#    add_header Content-Security-Policy "default-src "self"; script-src "self" "unsafe-inline" "unsafe-eval"; style-src "self" "unsafe-inline"" always;

#    access_log  logs/main-access.log;
#    error_log  logs/main-error.log;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
    location ~* /(system|vendor)/.*\.(txt|xml|md|html|htm|shtml|shtm|json|yaml|yml|php|php2|php3|php4|php5|phar|phtml|pl|py|cgi|twig|sh|bat)$ { return 403; }
    location ~* /user/.*\.(txt|md|json|yaml|yml|php|php2|php3|php4|php5|phar|phtml|pl|py|cgi|twig|sh|bat)$ { return 403; }
    location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }

}
"%UserProfile%\Desktop\nginx Reload.bat"

Initial Setup

Pages

Home

notepad++ "%SystemDrive%\www\main\user\pages\01.home"
---
title: Home
body_classes: title-center title-h1h2
---

Welcome! At Realm of Espionage, I offer unique computer optimization services, and present my wealth of knowledge of self-hosting websites and services on my wiki, [RoE | Wiki](https://wiki.realmofespionage.xyz/?target=_blank).

This website is an active work in-progress ([notes](https://wiki.realmofespionage.xyz/windows;servers;nginx;grav?target=_blank))!

CSS

notepad++ "%SystemDrive%\www\main\user\themes\quark\css\custom.css"
/* Link Color */
body a {
    color: #3D8BFF;
}

/* Header */
/* Blue background */
#header {
    background: #3D8BFF!important;
}

/* Header */
/* White text (links) */
#header a {
    color: #FFFFFF!important;
}

/* Header */
/* Hide logo (desktop) */
#header .logo svg {
  visibility: hidden;
}

/* Header */
/* Hide logo (mobile) */
.mobile-logo svg {
  visibility: hidden;
}

/* Footer */
/* Dark-gray background */
.bg-gray {
    background: #484848!important;
}

/* End */

Batch Files

PHP-CGI

  • This is using a sort-of hard-coded path for PHP instead of assuming it's in PATH
notepad++ "%UserProfile%\Desktop\Main php-cgi.bat"
CD "C:\php-"*"-nts-Win32-vs16-x64\"

SET PHP_FCGI_MAX_REQUESTS="0"
SET PHP_FCGI_CHILDREN="1"

START "Main PHP-CGI" php-cgi.exe -b "127.0.0.1:9001" -c "%SystemDrive%\www\php\main-php.ini"

:: End
"%UserProfile%\Desktop\Main php-cgi.bat"
/var/www/wiki/data/pages/servers/windows/nginx/grav.txt · Last modified: by 127.0.0.1