How to install inside LXC container (Alpine Linux)
See original GitHub issueHow to install grocy on Alpine Linux (running inside LXC container
Alpine is a minimalistic Linux distributions often being containerized inside Docker or LXC. The guide assumes you’re following the steps below a fresh Alpine Linux installation, all commands are to be run under root
user. The whole LXC container takes less than 200 MB.
grocy
is configured to be served on HTTP (port 80) and hence only LAN (where everyone is trusted) is assumed.
Parts of these instructions are taken from Alpine Wiki (https://wiki.alpinelinux.org/wiki/Nginx).
Pull latest packages
apk update
apk upgrade
Install dependencies (nginx
+ php
+ php sqlite
)
apk add php nginx php7-sqlite3 php7-fpm php7-pdo_sqlite php7-gd php7-fileinfo php7-tokenizer composer php7-ctype
Create a dedicated user/group for nginx
adduser -D -g 'www' www
Configure nginx
cat > /etc/nginx/nginx.conf <<HERE
user www;
worker_processes auto; # it will be determinate automatically by the number of cores
error_log /var/log/nginx/error.log warn;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
access_log /var/log/nginx/access.log;
keepalive_timeout 3000;
server {
listen 80;
root /www/public;
index index.html index.htm index.php;
try_files \$uri /index.php;
server_name localhost;
client_max_body_size 32m;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/lib/nginx/html;
}
location ~ \.php\$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
}
HERE
Create webroot
mkdir /www
chown -R www:www /var/lib/nginx
chown www:www /var/tmp/nginx
Configure php
PHP_FPM_USER="www"
PHP_FPM_GROUP="www"
PHP_FPM_LISTEN_MODE="0660"
PHP_MEMORY_LIMIT="512M"
PHP_MAX_UPLOAD="50M"
PHP_MAX_FILE_UPLOAD="200"
PHP_MAX_POST="100M"
PHP_DISPLAY_ERRORS="On"
PHP_DISPLAY_STARTUP_ERRORS="On"
PHP_ERROR_REPORTING="E_COMPILE_ERROR\|E_RECOVERABLE_ERROR\|E_ERROR\|E_CORE_ERROR"
PHP_CGI_FIX_PATHINFO=0
sed -i "s|;listen.owner\s*=\s*nobody|listen.owner = ${PHP_FPM_USER}|g" /etc/php7/php-fpm.d/www.conf
sed -i "s|;listen.group\s*=\s*nobody|listen.group = ${PHP_FPM_GROUP}|g" /etc/php7/php-fpm.d/www.conf
sed -i "s|;listen.mode\s*=\s*0660|listen.mode = ${PHP_FPM_LISTEN_MODE}|g" /etc/php7/php-fpm.d/www.conf
sed -i "s|user\s*=\s*nobody|user = ${PHP_FPM_USER}|g" /etc/php7/php-fpm.d/www.conf
sed -i "s|group\s*=\s*nobody|group = ${PHP_FPM_GROUP}|g" /etc/php7/php-fpm.d/www.conf
sed -i "s|;log_level\s*=\s*notice|log_level = notice|g" /etc/php7/php-fpm.d/www.conf
sed -i "s|display_errors\s*=\s*Off|display_errors = ${PHP_DISPLAY_ERRORS}|i" /etc/php7/php.ini
sed -i "s|display_startup_errors\s*=\s*Off|display_startup_errors = ${PHP_DISPLAY_STARTUP_ERRORS}|i" /etc/php7/php.ini
sed -i "s|error_reporting\s*=\s*E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = ${PHP_ERROR_REPORTING}|i" /etc/php7/php.ini
sed -i "s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i" /etc/php7/php.ini
sed -i "s|;*upload_max_filesize =.*|upload_max_filesize = ${PHP_MAX_UPLOAD}|i" /etc/php7/php.ini
sed -i "s|;*max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|i" /etc/php7/php.ini
sed -i "s|;*post_max_size =.*|post_max_size = ${PHP_MAX_POST}|i" /etc/php7/php.ini
sed -i "s|;*cgi.fix_pathinfo=.*|cgi.fix_pathinfo= ${PHP_CGI_FIX_PATHINFO}|i" /etc/php7/php.ini
sed -i "s|;extension=fileinfo|extension=fileinfo|" /etc/php7/php.ini
sed -i "s|;extension=gd2|extension=gd2|" /etc/php7/php.ini
sed -i "s|;extension=pdo_sqlite|extension=pdo_sqlite|" /etc/php7/php.ini
sed -i "s|;extension=sqlite3|extension=sqlite3|" /etc/php7/php.ini
Get and extract grocy
to webroot
# Adjust `ver` to (preferrably) the latest version found at https://github.com/grocy/grocy/releases
cd /www
pkgver=2.5.2
wget https://github.com/grocy/grocy/releases/download/v${pkgver}/grocy_${pkgver}.zip
unzip grocy_${pkgver}.zip
rm grocy_${pkgver}.zip
Adjust grocy
configuration, set correct permissions
cp config-dist.php data/config.php
# edit data/config.php (language, menu items, currency, etc)
chown -R www:www /www
Start php-fpm and enable it after boot
rc-service php-fpm7 start
rc-update add php-fpm7 default
Start nginx and enable it after boot
rc-service nginx start
rc-update add nginx default
test access to grocy in your browser
reboot server to check whether services are correctly started
Setup a regular backup of config.php
, /www/data/grocy.db
and /www/data/storage
tar cvzf /www/backup.tgz /www/data/config.php /www/data/grocy.db /www/data/storage
cp /www/backup.tgz SOME_PLACE_SAFE
# where SOME_PLACE_SAFE is probably a mount from a remote system
Troubleshooting
Check logs
tail -f /var/log/nginx/access.log
tail -f /var/log/nginx/error.log
tail -f /var/log/php7/error.log
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:18 (1 by maintainers)
Top Results From Across the Web
LXC - Alpine Linux Wiki
Linux Containers (LXC) provides containers similar to BSD Jails, Linux VServers and Solaris Zones. It gives the impression of virtualization ...
Read more >Is it possible to install linux containers on Alpine Linux? - Reddit
I'd like to run LXD / LXC on Alpine Linux, but all tutorials I found are concerned with running Alpine inside containers.
Read more >LXD Dashboard – Installing from source in Alpine Linux
Open a web browser and access the LXD dashboard by entering in the IP address of the instance. Use the lxc list command...
Read more >How to have Alpine Linux in LXC container working and running
First I will show you how to install Alpine in LXC containers and then we'll need to do some stuff like setup network...
Read more >Proxmox LXC container Alpine Linux - set up WireGuard VPN ...
II/ Install Alpine Linux as LXC container (Proxmox VE 7.1-7) ... is somehow throttled if the VM (wireguard peer) is inside proxmox VE....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also got my instructions in #201 to work, but only under webroot. I am going to update my instructions accordingly. Thanks again, it was a big help to see that yours worked!
I’m having an issue installing following this guide with 3.3.2. I realize it’s related to PHP 8 being required after Grocy v3.1, but I can’t figure out the commands to make it play nice. Could it be updated for v3+ ?