Skip to content

Commit 33abd07

Browse files
Merge pull request #532 from arduino/benjamindannegard/x8-webserver-tutorial
Benjamindannegard/x8 webserver tutorial
2 parents e91ad20 + 73ec4d7 commit 33abd07

File tree

5 files changed

+120
-0
lines changed

5 files changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
title: 'Running Wordpress and Database Containers on the Portenta X8'
3+
description: 'Learn how to run a database and Wordpress container on the Portenta X8'
4+
difficulty: beginner
5+
tags:
6+
- containers
7+
- Docker
8+
- Wordpress
9+
author: 'Benjamin Dannegård'
10+
software:
11+
- Terminal
12+
- Docker
13+
hardware:
14+
- hardware/04.pro/boards/portenta-x8
15+
---
16+
17+
## Overview
18+
19+
The Arduino Portenta X8 is a powerful board that has many features that can be easily utilized with the help of Docker containers. In this tutorial we will be using the Portenta X8 to host a webserver and run Wordpress using containers. This is a simple way to configure and run your own webserver and Wordpress page. We can then access the Wordpress site on the X8 through our web browser and begin setting it up.
20+
21+
## Goals
22+
23+
- Create the file to install docker containers
24+
- Install and run the containers
25+
- Connect to the Wordpress container running on the Portenta X8
26+
27+
### Required Hardware and Software
28+
29+
- [Arduino Portenta X8](https://store.arduino.cc/products/portenta-x8)
30+
- USB-C cable (either USB-C to USB-A or USB-C to USB-C)
31+
32+
## Instructions
33+
34+
First make sure your Portenta X8 is setup correctly by following the [getting started tutorial](https://docs.arduino.cc/tutorials/portenta-x8/out-of-the-box).
35+
36+
### Creating the Docker-compose.yml File
37+
38+
The Wordpress container we will be using also requires a webserver container. We will be using **mariadb** as our webserver container. This container can run on the Portenta X8's architecture. All we need to being installing these containers is to write a **docker-compose.yml** file. This file will contain information about what image we want to install and some important configuration information. Such as the username for the database, password, timezone and database name. The same goes for the Wordpress container, it will contain the password and username, we will also enter the database host name and which container it will use as the database. If you would like to change any password to a more secure one, feel free to replace the generic ones that are stated in the file below.
39+
40+
41+
### The Complete Docker-compose.yml File
42+
43+
In this section you can find the complete **docker-compose.yml** file that we will be using for this tutorial.
44+
45+
```
46+
version: "3.9"
47+
48+
services:
49+
db:
50+
image: lscr.io/linuxserver/mariadb:latest
51+
container_name: mariadb
52+
environment:
53+
- PUID=1000
54+
- PGID=1000
55+
- MYSQL_ROOT_PASSWORD=Wordpress
56+
- TZ=Europe/London
57+
- MYSQL_DATABASE=Wordpress
58+
- MYSQL_USER=Wordpress
59+
- MYSQL_PASSWORD=Wordpress
60+
volumes:
61+
- db_data:/var/lib/mysql
62+
restart: unless-stopped
63+
64+
Wordpress:
65+
depends_on:
66+
- db
67+
image: Wordpress:latest
68+
volumes:
69+
- Wordpress_data:/var/www/html
70+
ports:
71+
- "8000:80"
72+
restart: always
73+
environment:
74+
Wordpress_DB_HOST: db
75+
Wordpress_DB_USER: Wordpress
76+
Wordpress_DB_PASSWORD: Wordpress
77+
Wordpress_DB_NAME: Wordpress
78+
volumes:
79+
Wordpress_data: {}
80+
db_data: {}
81+
```
82+
83+
Now lets create a directory on our X8 and put this **docker-compose.yml** file on our device.
84+
85+
### Installing The Containers
86+
87+
First we create a directory where we want put our **docker-compose.yml** file. Using the `mkdir` command we will create a directory named "wordpress-test". Navigate into this directory with a simple `cd` command. Either copy the docker-compose.yml file into this directory or create it directly here.
88+
89+
![cd into correct directory](assets/webserver-mkdir.png)
90+
91+
Before installing the containers, make sure that no other container is running on the ports that the Wordpress container will use. You can check what containers are running and what port they are using by running the `docker ps -a` command. This will show a list of the currently installed and running containers on the Portenta X8. To remove a container first stop it with `docker stop <container id>`, then you can run `docker rm <container id>` to remove it. If you want more information about handling containers on your Portenta X8, take a look at our [managing containers with docker tutorial](https://docs.arduino.cc/tutorials/portenta-x8/docker-container).
92+
93+
When you are in the correct directory and no other container is running on the ports that Wordpress will use, we can now run `docker compose up`. This will start installing the **Wordpress** and **mariadb** containers. You can follow the progress in the terminal, it can take a while. Once it is done we can connect to the device and site.
94+
95+
![Containers install progress in the terminal](assets/webserver-container-install.png)
96+
97+
### Connecting to the Wordpress Site
98+
99+
To connect to the Wordpress setup site we simply need to access it with our Portenta X8s unique id and port. So for example `http://<uuid>.local:<port>`, where you would substitute the `<uuid>` with your Portenta X8s unique id and the port chosen for the Wordpress container with `<port>`. The `<uuid>` can be found on the setup page that is showed in the [Getting started tutorial](https://docs.arduino.cc/tutorials/portenta-x8/out-of-the-box), you can also see it in the terminal when running `adb`. Or you can go to `http://192.168.7.1:8000` if you use Windows and Linux, on MacOS use `http://192.168.8.1:8000`.
100+
101+
When you connect you should get some feedback in the terminal. Text will begin printing in the terminal, showing you information about the connection that has just been established. Like shown in the image below.
102+
103+
![Terminal printout during connection](assets/webserver-connect-terminal.png)
104+
105+
Now you should see a webpage like on the next image in your browser.
106+
107+
![Wordpress setup site](assets/webserver-wordpress-site.png)
108+
109+
You are now free to go through the Wordpress set up process and configure it however you like.
110+
111+
## Conclusion
112+
113+
In this tutorial we went through how to install and run a Wordpress and database container on the Portenta X8. We then accessed the Wordpress site on our X8 through our web browser. So now you can setup your own Wordpress site on your X8 device and access it from another device.
114+
115+
116+
## Troubleshooting
117+
118+
- If the containers aren't installing or running correctly check if there are any other containers currently running on the same ports as the ones used by the Wordpress container. You can check this with ``docker ps -a``.
119+
- If there is any issue running docker commands, make sure you are using ``sudo`` before the commands.
120+
- If you can't connect to the site when everything is running you can double check the X8s ip address. Run the command `ip s a` in the adb shell. This will display the X8s ip address via usb and wifi. Try connecting via those ip addresses if all else fails.

0 commit comments

Comments
 (0)