How I installed HestiaCP on LXC container for PHP develpment in LInux

Before moving to Linux, I used to use Laragon for web development. It was nice and could manage virtual hosts. It had a terminal with git bash and you could switch PHP versions, enable disable xdebug and more features. In Linux, you don’t have such alternatives.

On the beginning, I used to use vestaCP docker image I found on GitHub. The developer had stopped pushing updates to that docker image. I also stumbled upon some bugs. I searched for alternatives and have found Hestia. It was beautiful looking and I’m impressed! It is easy to use and I started installing Hestia on my LXC container and have modified some scripts to make it work on local network environment only.

The process is the following:

Firstly, spawn a Ubuntu 20.04 container

lxc launch ubuntu:20.04 myhestiacp

After the LXC container is started

lxc shell myhestiacp

Edit the mirror address to your nearest location. (/etc/apt/sources.list)
Then, download and run the installation script

curl -LO
bash --apache yes --phpfpm yes --multiphp yes --vsftpd yes --proftpd no --named yes --mysql yes --postgresql no --exim no --dovecot no --sieve no --clamav no --spamassassin no --iptables no --fail2ban yes --quota no --api yes --interactive yes --hostname box.myhestiacp.lxd --email [email protected] --password no --with-debs no  --port 8083 --lang en

You may stumble across the error “Error: User admin exists”

groupdel admin

Run the previous command again. After finishing the setup, copy the admin password and store it in a safe place. You will be prompted to hit the return key and the container will reboot and you are disconnected from the shell.

Now access the container shell again and find out the internal IP address being used.

ip addr

Then edit the file rc.local and comment out the following line


From the output, you will see the second interface that has IP address beginning with 10.xx.xx.xx
Copy the address to a sticky note for later use.

Now, here is the DNS query setup part!

LXC has it’s own DNS resolving system with DHCP management via dnsmasq, you have to forward the DNS queries to LXC container’s DNS. I use dnscrypt-proxy to forward the DNS.

If you don’t have dnscrypt-proxy installed, install it and set it up for your general DNS queries.

After you have the dnscrypt-proxy installed, setup the forwarding rules by creating the file

test #the internal ip address 
lxd #the gateway IP address for the LXC network, same as the container IP, but the fourth number is replaced by 1

Verify you include the file on dnscrypt-proxy.toml

forwarding_rules = 'forwarding-rules.txt'

Now, login to the admin dashboard : https://myhestiacp.lxd:8083/

Then, go to Settings > Configure > Network. From the first network, set NAT IP Association same value as IP Address and save.

Create sites with (dot) test at the end of domain name. It can be any name ending with test. For example: mysite.test

Finally, go to your browser and try to access http://mysite.test
Viola! You have a woking local installation of HestiaCP!

You can use VSCode SSH remote to edit files.

Just curious. How much space does the lxc hestia install take up? Previously if I needed a local Hestia install, I probably would have done it in VirtualBox, but you’re looking at a 3-4Gb container for a base install. Using lxc I understand that it will ‘re-use’ the base system from the local machine, so you don’t need a complete new copy of Ubuntu. So, I’m curious how big an LXC hestia container is.

I ran du against the lxc storage directory /var/snap/lxd/common/lxd/storage-pools/default/containers/hestiacp/rootfs. It shows 6.2G. I am using dir as storage driver.