Minimal Ubuntu 20.04 system setup with nginx, grocy > 2.6.0, php 7.4
See original GitHub issueStarting 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:
- Created 3 years ago
- Reactions:9
- Comments:35 (4 by maintainers)
Top GitHub Comments
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.apt update
apt full-upgrade -y
apt install -y nginx sqlite3 php-fpm php-sqlite3 php-gd unzip
wget https://releases.grocy.info/latest
unzip latest -d /var/www/html
chown -R www-data:www-data /var/www
cp /var/www/html/config-dist.php /var/www/html/data/config.php
ip addr
nano /etc/nginx/conf.d/fastcgi_params
and paste the following into the new file: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):systemctl restart nginx.service
That’s mentioned in README.