question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Minimal Ubuntu 20.04 system setup with nginx, grocy > 2.6.0, php 7.4

See original GitHub issue

Starting with grocy 2.6.1 and the switchover from the Slim framework v3 to v4, you cannot install in a subdirectory anymore.

Here the updated instructions which work for me on a minimum Ubuntu 20.04 install on a ARM system:

Install nginx, php, sqlite on minimal system

Get root, ideally with sudo -i.

Install nginx and check status, should be up and running. You can make extra sure with systemctl enable nginx that this survives a reboot.

apt install nginx
systemctl status nginx

If you are not starting from a minimal system, make sure that the firewall (ufw or other) don’t interfere with the nginx install:

ufw allow 'Nginx Full'

and check with ufw status. This opens the firewall for HTTP and HTTPS on ports 80 and 443.

Now you can install sqlite with apt install sqlite3.

To install only php without the Apache dependency, install php-fpm together with php-gd. Don’t forget php-sqlite3.

apt install php-fpm php-sqlite3 php-gd

The standard www root directory is /var/www/html/, the user for nginx is set to ‘www-data’.

The files served need to belong to this user.

cd /var/www/html
wget https://releases.grocy.info/latest
unzip latest -d /var/www/html && rm latest
chown -R www-data:www-data /var/www
cp /var/www/html/config-dist.php /var/www/html/data/config.php
vi /var/www/html/data/config.php

Now is the time to do the edits to customize your installation.

Important: BASE_PATH and BASE_URL need to be setup like this:

# When running grocy in a subdirectory, this should be set to the relative path, otherwise empty - this will not work currently with Grocy 2.6.1!
# Example:
#  Webserver root directory = /var/www
#  grocy directory = /var/www/grocy
#  => BASE_PATH = /grocy
Setting('BASE_PATH', '');

# The base url of your installation,
# should be just "/" when running directly under the root of a (sub)domain
# or for example "https://example.com/grocy" when using a subdirectory
Setting('BASE_URL', '/');

Do not try and put grocy in a subdirectory. This seems not to work at the moment with Slim v4 and Grocy 2.6.1.

Test your install with http://localhost or http://<intranet_server_name> from elsewhere. The default nginx landing page should come up to indicate that the web server part is running.

Now to configure the server and php. There are several .ini and .conf files now in your /etc/php folder, you can leave them alone. Same goes for the /etc/nginx/nginx.conf file. What you want to do is to make a file /etc/nginx/conf.d/fastcgi_params to setup your installed system correctly:

include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

Make sure that the last line fits your installed php version. Test with php --version if necessary.

To set the web root, do the following:

cd /etc/nginx/sites-available
cp default grocy
ln -s /etc/nginx/sites-available/grocy /etc/nginx/sites-enabled/grocy
rm /etc/nginx/sites-enabled/default

Now edit the grocy file with the following changes:

 root /var/www/html/public;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html index.php;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri /index.php;
                #try_files $uri $uri/ =404;
        }

        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;

                # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; #need to edit this!

        #       # With php-cgi (or other tcp sockets):
        #       # fastcgi_pass 127.0.0.1:9000:
        }
}

Again, make sure that the line to be edited fits your installed php version like above.

On reload of nginx with systemctl restart nginx.service, you should be able to access the grocy pages now. Or, if necessary, reboot. I also had issues with my Chrome browser which mandated a cache deletion. Grocy should now work without issues.

If anyone can add to this how to install in a subdirectory of the webserver root, I would be happy to amend the above.

_Originally posted by @emk2203 in https://github.com/grocy/grocy/issues/201#issuecomment-487074462_

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:35 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
pconwellcommented, Dec 7, 2020

If anyone comes across this in the future, the instructions above are confusing and jumbled (why are there like 3 different apt install instances? And why were there a bunch of files mentioned that we don’t need to edit?). Here are clean instructions that will work for (proxmox lxc) minimal Debian 10.7 and probably most variants of debian/ubuntu. I started with a completely new, clean install of Debain 10.7.

Note: If your install came with a newer version of php, you will need to change php7.3 to php7.4 (or whatever version) in the instructions below. The easiest way to determine your correct php version is to cd /var/run/php/ and see what php7.X-fpm.sock pointer is located there.

  1. Install clean minimal Debian 10.7 install (will probably work with most debian/ubuntu variants)
  2. apt update
  3. apt full-upgrade -y
  4. apt install -y nginx sqlite3 php-fpm php-sqlite3 php-gd unzip
  5. wget https://releases.grocy.info/latest
  6. unzip latest -d /var/www/html
  7. chown -R www-data:www-data /var/www
  8. cp /var/www/html/config-dist.php /var/www/html/data/config.php
  9. ip addr
  10. In your browser, check if nginx is running at http://ip_addr (from above)

Note: If you are using ubuntu and/or a full fledge install (not a minimal/server install), you may need to configure your firewall. Not covered here.

  1. nano /etc/nginx/conf.d/fastcgi_params and paste the following into the new file:
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
  1. nano /etc/nginx/sites-available/default and make the file look just like this (you can just delete all the old stuff and copy this):
server {
        listen 80 default_server;

        root /var/www/html/public;

        index index.html index.htm index.nginx-debian.html index.php;

        server_name _;

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

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        }
}
  1. systemctl restart nginx.service
  2. Go back to your http://ip_addr and you should now see the login for grocy. May take a few minutes to load.

Note: Default username/password is admin/admin, OR you can disable authentication by changing Setting('DISABLE_AUTH', false); to true in /var/www/html/data/config.php

1reaction
berrndcommented, Dec 1, 2020

One additional question: How would I have to install any future update when it comes out?

That’s mentioned in README.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Links | grocy
Installing Bleeding Edge grocy on Raspberry Pi OS (Debian 11) ... Minimal Ubuntu 20.04 system setup with nginx, grocy > 2.6.0, php 7.4....
Read more >
How to install PHP 7.4 With Nginx on Ubuntu 20.04
By default, Ubuntu 20.04 ships with PHP 7.4 in its upstream repositories. You can install it easily by just running the following command:...
Read more >
Ubuntu and Apache Install : r/grocy - Reddit
I started with a minimal install of either Ubuntu 18.04 LTS or 20.04 LTS. Other than the base system only OpenSSH server was...
Read more >
How To Install PHP 7.4 and Set Up a Local Development ...
This tutorial will guide you through installing PHP 7.4 on Ubuntu and setting up a local programming environment via the command line.
Read more >
Install Nginx With PHP-FPM on Ubuntu 22.04|20.04
Nginx has small memory footprint as compared to Apache, handling same number of concurrent connections. Features of Nginx Web Server. Content ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found