Help - LAMP Server or equivalent on SCALE

Hi, I am new to TrueNAS Scale and an amateur / hobbyist, so please be gentle!

Hardware: The setup is a Jonsbo N1 Case, the CPU is an N100 with 32Gb RAM. It contains a couple of pools, one is a small 1 Tb Pool consisting of two disks mirrored, the other is a mirrored 12Tb pool for backups.
My Task: On the smaller 1Tb Pool I would like to add a simple Web, PHP and SQL server, NodeRed would also be handy if possible. I have set up LAMP servers on a Raspberry Pi and would like to replicate something similar here. It is only to handle my own IOT projects.
I have looked on forums and YouTube but my requirement is obviously a long way from commercial setups so I have not found much advice.

Do I set up custom apps? I have been trying to understand Kubernetes, is that the answer? Should I use a VM with a light weight linux install and just go LAMP? If so, what distro of linux would you recommend?

Any advice is gratefully received. Thanks.

Edit: Debian seems to be the light Distro of choice, unless there are any strong opinions on here I’ll probably go with a Debian LAMP in a VM

Since iX has decided to throw out k3s in a few months, no, unless you want to set up and maintain your own k3s cluster.

There are really two decent answers, one of which you’ve already mentioned:

  • Install your preferred OS (Ubuntu Server would be a popular choice) in a VM, and whatever you want on that OS; or
  • Use a sandbox/jail to run your software. @Stux is quite the fan of this option and has put together a video on using them.
2 Likes

I set up a LEMP stack using dockge and its docker compose ability. Very easy in the end.

Steps:

  1. Watch stux’s now world famous video on setting up docker in a jailmaker jail:
    https://www.youtube.com/watch?v=S0nTRvAHAP8&t=2s
  2. Use dockge to install your LAMP/LEMP stack. My LEMP stack compose file is as follows:
version: "3.8"
services:
  nginx:
    image: nginx:latest
    restart: unless-stopped
    ports:
      - 8080:80
    volumes:
      - ./www:/var/www/html
      - ./default.conf:/etc/nginx/conf.d/default.conf
      - ./.htpasswd:/etc/nginx/.htpasswd
    links:
      - php-fpm
    depends_on:
      - php-fpm
  php-fpm:
    image: chialab/php:8.3-fpm
    volumes:
      - ./www:/var/www/html
      - ./php.ini:/usr/local/etc/php/php.ini
    depends_on:
      - mariadb
    restart: unless-stopped
  # MariaDB Service
  mariadb:
    image: mariadb:10.9
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: REDACTED
    volumes:
      - ./mysqldata:/var/lib/mysql
  # phpMyAdmin Service
  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    restart: unless-stopped
    ports:
      - 8081:80
    environment:
      PMA_HOST: mariadb
    depends_on:
      - mariadb
networks: {}

You can set the ports up to your liking. Note you can also insert / mount your own config files e.g. php.ini, .htpasswd, default.conf and website (index.html etc) files by mounting volumes as above.

The directories can easily be mounted and managed using (for example) WinSCP or Filezilla. Using stux’s recommended docker/dockge setup, your base nginx directory will be /mnt/tank/docker/stacks/nginx/

Good luck!

2 Likes

Hi, Thanks for the help. I have managed to get Capt Stux jailmaker working. I am stuck on the LEMP bit though. I have tried to compose for a simple nginx installation. my compose file is as follows:

version: "3.8"
services:
  nginx:
    image: nginx:latest
    restart: unless-stopped
    ports:
      - 8080:80
    volumes:
      - /mnt/ReadyNAS-1Tb/docker/data/nginx/www:/www
      - /mnt/ReadyNAS-1Tb/docker/data/nginx/config:/config
networks: {}

I have gone to the IP:8080 and it works fine.

I have gone to /mnt/ReadyNAS-1Tb/docker/data/nginx/www in Putty and have touched an html file there, index.html, I have entered some html boilerplate. Despite refreshing, the nginx is still showing me the standard nginx landing page though, not my boiler plate. I have gone into /mnt/ReadyNAS-1Tb/docker/data/nginx/config/ and there is no config folder?

Can you spot what I have done wrong? Thanks.

A couple of points to note:

  1. The deployment should generate its own config files and folder structures. However, the (optional) reason for specifying these in the docker compose is to allow you to have custom configurations (in the case of the nginx.conf file) and to specify the location of the /www files you wish to serve. It also means when the container is rebuilt / updated, that you don’t have to manually update / edit the files each time - they will be mounted into the docker container when it’s rebuilt.
  2. For volumes, the left side of the colon is the host system path. The right side of the colon is the mount point in the container. So:
    “- ./www:/var/www/html” will mount the host directory “www” into the nginx container at /var/www/html.
    “- ./default.conf:/etc/nginx/conf.d/default.conf” will mount the file “default.conf” on the host system into the nginx container as /etc/nginx/conf.d/default.conf.

I have had some trouble with mounts too, including where it mounts the file (e.g. php.ini as a directory, rather than inserting it as a file, and I’m not sure why. However, the LEMP stack compose I posted seems to work as intended!

In your case, make sure that “/mnt/ReadyNAS-1Tb/docker/data/nginx/www” is mounted properly in the jailmkr jail which is hosting your docker/dockge install. You can do this in TrueNAS shell with “jlmkr edit docker”, and adjusting the mounts e.g. --bind=‘/mnt/ReadyNAS-1Tb/docker/data/nginx/www:/www’

You should then be able to navigate to ‘/www’ on the docker host and find your www files.

I should also add, I’m no expert, having just learnt this stuff a month or so ago when Ix and Truecharts decided to ditch the kubernetes apps system and move to docker.