Just a short intro. So LXD/LXC it creates an isolated container I just discovered the power of Ansible where it deploys and manage a server/container. So I was thinking that just use a linux script to automate all creating a linux container and install a WordPress site.

I created a simple shell script that automates these process:

  • Create an isolated linux container using LXD/LXC
  • The script deploy all the required apps like using Ansible (playbook).
  • Required apps like: php, mysql, nginx and, WordPress other PHP extension for WordPress requirements.
  • Add a proxy port 8080 using LXC proxy device so that the linux container is accessible around the globe.

Setting up a WordPress with LEMP (Linux, Nginx, MySQL, PHP) from scratch will take a lots of linux commands to do that (but you can just using other lamsp to do that for you.).

Linux shell script source

So I created a simple linux script to automate that process using Ansible loading all the apps to an to a linux container (LXC).


git clone
cd lxc-lemp-wp

Adding a proxy device

My main host is a Linux Ubuntu 18.04 from Google Cloud Platform (n1-standard-4 -4 vCPUs, 15 GB memory)

And I am using lxc proxy device to proxy my LXC container so that my WordPress site will be available accessing from the Internet and I also created an article for that here.

Example command to add a proxy device for port 8080 tarting the LXC name wordpress with the device name myport8080.

lxc config device add wordpress myport8080 proxy listen=tcp: connect=tcp:localhost:80                     

Video demo:

Destroy and clean up.

You can use this command to clean up the container and files generated by the scrip.

./ clean

I hope you enjoyed this article and that video! Have fun! 🙂

Subscribe To Our Newsletter

Join our mailing list to receive the latest website layout designs, news and updates from our team.

You have Successfully Subscribed!

Share This