• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Install Grav on Nginx : Modern, Flat File, PHP Powered CMS

By Abhishek Ghosh June 11, 2016 8:41 pm Updated on June 11, 2016

Install Grav on Nginx : Modern, Flat File, PHP Powered CMS

Advertisement

There are lot of PHP powered Static Website builders now. Grav is A Modern, Light, File-Based, PHP Powered CMS Suitable For Small Blog, Profile Website, Documentation, Official Website of Business. Here is How to Install Grav on Nginx on Ubuntu 16.04 LTS Cloud Server Instance. . This is also a self-reminder that Grav exists.

Install-Grav-on-Nginx---Modern,-Flat-File,-PHP-Powered-CMS

 

How to Install Grav on Nginx on Ubuntu 16.04 : Before We Begin

 

Grav has a built-in command-line interface (CLI) installed at bin/grav. This CLI is extremely useful for running day to day tasks such as updating, clearing cache, creating backups, and more. It is a Flat-File CMS – which makes database headache free. PHP is bad but PHP is the practical option in most of cases. One major reason of using WordPress is PHP. But WordPress is too heavy now. Making new WordPress installation lighter sucks a huge time. Basically, WordPress – Joomla – Drupal – Magento are the practical options. After Jekyll, OctoPress came; it became quite popular. But Ruby is not exactly easy to publish a post. We can not easily use the PHP functions directly. With Grav, we can see the created files with any FTP software like FileZilla or using Command Line File Browser. In other words – everything can be done from SSH, however there is a decent web GUI for the Admin part.

We are using the word CMS quite loosely. WordPress in strict sense is not a CMS but basically WordPress is also not only a blogging software.

Advertisement

---

 

 

This is GitHub Repository of Grav :

Vim
1
https://github.com/getgrav/

If you are running Nginx, then this is your normal webroot in deb based GNU/Linux :

Vim
1
/usr/share/nginx/html

If you are NOT running Nginx, then follow our Nginx-WordPress-Ubuntu 16.04 guide to Install only Nginx and PHP part.

Now, first cd to /usr/share/nginx/html and do these steps :

location = /usr/share/nginx/html
Vim
1
2
3
4
5
6
cd /usr/share/nginx/html
adduser grav
locate www.conf
## cd to the path of ..fpm/pool.d/
## where www.conf resides
nano grav.conf

Add the following :

location = grav.conf
Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
[grav]
 
user = grav
group = grav
listen = /var/php/php7.0-fpm.grav.sock;
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /

This is an approximate default nginx configuration for Nginx, Ubuntu 16.04, PHP-FPM :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
server {
    listen 80 default_server;
    root /usr/share/nginx/html/grav;
    index index.html index.htm index.php;
    server_name localhost;
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }
# for grav starts
location /user {
rewrite ^/user/accounts/(.*)$ /error redirect;
rewrite ^/user/config/(.*)$ /error redirect;
rewrite ^/user/(.*)\.(txt|md|html|php|yaml|json|twig|sh|bat)$ /error redirect;
}
location /cache {
rewrite ^/cache/(.*) /error redirect;
}
location /bin {
rewrite ^/bin/(.*)$ /error redirect;
}
location /system {
rewrite ^/system/(.*)$ /error redirect;
}
location /vendor {
rewrite ^/vendor/(.*)$ /error redirect;
}
access_log off;
        error_log  /var/log/nginx/grav-error.log error;
sendfile off;
# for grav ends
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        # fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        fastcgi_pass unix:/var/php/php7.0-fpm.grav.sock;
        include fastcgi_params;
    }
## Begin - Security
    location ~* /(.git|cache|bin|logs|backups)/.*$ { return 403; }
    location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
    location ~* /user/.*\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
    location ~ /(LICENSE|composer.lock|composer.json|nginx.conf|web.config|htaccess.txt|\.htaccess) { return 403; }
## End - Security
 
}

To run the Grav CLI to create a new project, we need to go the webroot. We can change our username to grav.

location = /usr/share/nginx/html
Vim
1
2
3
4
5
6
7
cd /usr/share/nginx/html
git clone https://github.com/getgrav/grav.git
cd grav
su grav
bin/grav install
# example to install admin plugin
bin/gpm install admin

Admin will be at :

Vim
1
http://yoursite.com/admin

Here is Plugin and Grav CLI docs :

Vim
1
https://learn.getgrav.org/cli-console/grav-cli-plugin

They have another CLI tool :

Vim
1
https://learn.getgrav.org/cli-console/grav-cli-gpm

We need to add alias php="php-cli" in .bashrc. Restart the services :

Vim
1
2
sudo systemctl restart php7.0-fpm
service nginx restart

Install Grav on Nginx : Modern, Flat File, PHP Powered CMS

Tagged With flat file nginx , grav nginx alias , grav nginx Cache , grav on nginx , running grav php -S , small cms php nginx
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Install Grav on Nginx : Modern, Flat File, PHP Powered CMS

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud

    Here is a Step by Step Guide on Setting Up WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud with All Commands and the Configuration.

  • Steps To Install Nginx Plus on Ubuntu Server (HP Cloud)

    Here Are the Steps To Install Nginx Plus on Ubuntu Server Running on HP Cloud. Nginx Plus is the Paid Version of Nginx with Extra Features.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy