index

Yesterday I found out that octobercms had become premium. Well I liked it but not enough to pay for it. So I decided I would give Grav a go. It is a php flat file cms. 2 days now it seems nice. Everything is working as expected. Supports markdown extra which is similar to Kramdown in ruby. You must enable markdown extra in the admin panel. I have installed 2 setups one from a skeleton and the other with composer.

composer create-project getgrav/grav public_html/grav

The other which is /public_html/gravSkeleton was downloaded as zip and the use scp -r to transfer to server.


ubuntu

You should never have to run a website from within your home directory. EVER

  1. Allow Nginx access to the folders and files.
sudo chgrp -R www-data /var/www/html
sudo find /var/www/html -type d -exec chmod g+rx {} +
sudo find /var/www/html -type f -exec chmod g+r {} +
  1. Give your owner read/write privileges to the folders and the files, and permit folder access to traverse the directory structure.
sudo chown -R dna /var/www/html/
sudo find /var/www/html -type d -exec chmod u+rwx {} +
sudo find /var/www/html -type f -exec chmod u+rw {} +
  1. Make sure every new file after this is created with www-data as the 'access' user.
sudo find /var/www/html -type d -exec chmod g+s {} +
  1. Final security cleanup, if you don't want other users to be able to see the data
sudo chmod -R o-rwx /var/www/html/

Did all the above and I can write as use in /var/www/html within the directory it has change it to dna:www-data. Make sure you change dna:www-data


sudo vim /etc/php/7.4/fpm/pool.d/www.conf
find where it says 
user = www-data  change to user in this case dna
group = www-data

vim /etc/nginx/site-availible/grav_loc.conf create a new file


server {
    #listen 80;
    index index.html index.php;

    root /var/www/html/composer_grav_loc; 
    server_name grav.loc;
    

    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|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
    location ~* /user/.*\.(txt|md|json|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
    location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    }
}

Then do a ln -s /etc/nginx/sites-availible/grav_loc.conf /etc/nginx/sites-enabled/grav_loc.conf

restart nginx and fpm

Then open up windows host file.

127.0.0.1  grav.loc

Then you should be able to see your server

Date Modified: 2022-02-10