Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9bbc0f8

Browse files
Merge pull request #949 from arduino/jorgetrujilloroman/portenta-x8/wordpress-docker-redef
[PC-1197] Wordpress and Database Portenta X8 Tutorial Update
2 parents eb75119 + a9ed6f5 commit 9bbc0f8

File tree

2 files changed

+65
-18
lines changed

2 files changed

+65
-18
lines changed
Binary file not shown.

‎content/hardware/04.pro/boards/portenta-x8/tutorials/13.wordpress-webserver/content.md‎

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@ The Arduino Portenta X8 is a powerful board that has many features that can be e
2828

2929
- [Arduino Portenta X8](https://store.arduino.cc/products/portenta-x8)
3030
- USB-C® cable (either USB-C® to USB-A or USB-C® to USB-C®)
31+
- The [docker-compose.yml](assets/docker-compose.rar) file used in this tutorial
3132

3233
## Instructions
3334

34-
First, make sure your Portenta X8 is set up correctly by following the [User Manual's Out-of-the-box experience](https://docs.arduino.cc/tutorials/portenta-x8/user-manual#out-of-the-box-experience).
35+
First, make sure your Portenta X8 is set up correctly by following the [User Manual's Out-of-the-Box Experience](https://docs.arduino.cc/tutorials/portenta-x8/user-manual#out-of-the-box-experience).
3536

36-
### Creating the Docker-compose.yml File
37+
### Creating the **docker-compose.yml** File
3738

38-
The WordPress container we use is a multi-container application, which also requires a database server container. The WordPress multi-container application uses Apache as its web server. This is required to make the service work and it is already included in the container, so it is nothing for us to worry about. We will be using **MariaDB** as our database server container. This container can run on the Portenta X8's architecture. All we need to start using 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 and we will also enter the database hostname and which container will be used as the database. We recommend that you change the default passwords to more secure ones by replacing the default ones that are stated in the file below.
39+
The WordPress container we use is a multi-container application, which also requires a database server container. The WordPress multi-container application uses Apache as its web server. It is required to make the service operational and comes included within the container. We will be using MariaDB as our database server as a container instance.
3940

41+
This container can run on the Portenta X8's architecture. To start using these containers is to build a docker-compose.yml file. This file contains information regarding what image we want to install and important configuration details, such as the username for the database, password, timezone, and database name. The same goes for the WordPress container: it will include the password and username. We will also enter the database hostname and which container will be used as the database. We recommend changing the default passwords to more secure ones by replacing the default password defined in the file below.
4042

41-
### The Complete Docker-compose.yml File
43+
### The Complete **docker-compose.yml** File
4244

4345
In this section, you can find the complete **docker-compose.yml** file that we will be using for this tutorial.
4446

@@ -64,39 +66,65 @@ services:
6466
Wordpress:
6567
depends_on:
6668
- db
67-
image: Wordpress:latest
69+
image: wordpress:latest
6870
volumes:
6971
- Wordpress_data:/var/www/html
7072
ports:
7173
- "8000:80"
7274
restart: always
7375
environment:
74-
Wordpress_DB_HOST: db
75-
Wordpress_DB_USER: Wordpress
76-
Wordpress_DB_PASSWORD: Wordpress
77-
Wordpress_DB_NAME: Wordpress
76+
WORDPRESS_DB_HOST: db
77+
WORDPRESS_DB_USER: Wordpress
78+
WORDPRESS_DB_PASSWORD: Wordpress
79+
WORDPRESS_DB_NAME: Wordpress
7880
volumes:
7981
Wordpress_data: {}
8082
db_data: {}
8183
```
8284

83-
Now let's create a directory on our X8 and put this **docker-compose.yml** file on our device.
85+
Now let's create a directory on our X8 and put this **docker-compose.yml** file on our device. You can download the file by clicking [here](assets/docker-compose.rar).
8486

8587
### Installing The Containers
8688

87-
First, we create a directory where we want to add 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. To create the file, we can use `cat > docker-compose.yml`, this will create the file, so you can copy the content of the file from above and paste it. Push enter once to go to a new line and press `ctrl C` to exit the file editor. To copy the file from your computer onto the device use: `adb push <path to docker-compose.yml file> /home/fio/wordpress-test`.
89+
First, we create a directory where we want to add 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.
90+
91+
To create the file, we can use `cat > docker-compose.yml`, this will create the file, so you can copy the content of the file from above and paste it. Push enter once to go to a new line and press `ctrl C` to exit the file editor. To copy the file from your computer onto the device use:
92+
93+
```
94+
adb push <path to docker-compose.yml file> /home/fio/wordpress-test
95+
```
96+
97+
Alternatively, you could place the `docker-compose.yml` file inside the `wordpress-test` directory and push the file using the following command:
98+
99+
```
100+
adb push .\wordpress-test\ /home/fio
101+
```
102+
103+
Both options work fine and depend on how you would like to handle the file.
88104

89105
![cd into correct directory](assets/webserver-mkdir.png)
90106

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).
107+
***Remember that you may need to run the next command to gain admin access for running the Docker's commands: `sudo su -` which default password is `fio`***
108+
109+
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.
110+
111+
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).
112+
113+
When you are in the correct directory and no other container is running on the ports that WordPress will use, you can now run `docker compose up -d`. Using the `-d` tag in the command will allow running these containers in the background. If you run the command without the `-d` tag, the application will exit when you close the terminal.
92114

93-
When you are in the correct directory and no other container is running on the ports that WordPress will use, you can now run `docker compose up -d`. Using the `-d` tag in the command will allow running these containers in the background. If you run the command without the `-d` tag, the application will exit when you close the terminal. When the command is executed it will start installing the **WordPress** and **MariaDB** containers. This can take a while. To get the output from the containers use: `docker-compose logs -f`. Once it is done you can connect to the device and site.
115+
When the command is executed it will start installing the **WordPress** and **MariaDB** containers. This can take a while. To get the output from the containers use: `docker-compose logs -f`. Once it is done you can connect to the device and site.
94116

95117
![Containers install progress in the terminal](assets/webserver-container-install.png)
96118

97119
### Connecting to the WordPress Site
98120

99-
To connect to the WordPress setup site, you simply need to access it with your Portenta X8s unique id and port. So for example: `http://portenta-x8-<uuid>.local:<port>`, where you would substitute the `<uuid>` with your Portenta X8's unique id and the port chosen for the WordPress container with `<port>`. The `<uuid>` can be found on the setup page that is shown in the [User Manual's Out-of-the-box experience](https://docs.arduino.cc/tutorials/portenta-x8/user-manual#out-of-the-box-experience), but 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`.
121+
To connect to the WordPress setup site, you simply need to access it with your Portenta X8's unique id and port. So we can use the following address format:
122+
123+
```
124+
http://portenta-x8-<uuid>.local:<port>
125+
```
126+
127+
Where you would substitute the `<uuid>` with your Portenta X8's unique id and the port chosen for the WordPress container with `<port>`. The `<uuid>` can be found on the setup page that is shown in the [User Manual's Out-of-the-Box Experience](https://docs.arduino.cc/tutorials/portenta-x8/user-manual#out-of-the-box-experience), but you can also get 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`.
100128

101129
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 as shown in the image below.
102130

@@ -108,13 +136,32 @@ Now you should see a webpage, like the following image, in your browser.
108136

109137
You are now free to go through the WordPress setup process and configure it however you like.
110138

139+
### Removing the containers ###
140+
141+
If you want to remove the container, you have to go to ```/home/fio/wordpress-test``` directory (where we previously executed the docker-compose command) and execute the following commands according to your needs:
142+
143+
Remove the container but preserves your WordPress database:
144+
145+
```
146+
docker compose down
147+
```
148+
149+
Remove the container and the database:
150+
151+
```
152+
docker compose down --volumes
153+
```
154+
155+
To make sure that it was successful, run ```docker ps -a``` and check that the WordPress and MariaDB containers have disappeared.
156+
111157
## Conclusion
112158

113159
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 set up your own WordPress site on your X8 device and access it from another device.
114160

115-
116161
## Troubleshooting
117162

118-
- If the containers are not 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 cannot 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 X8's IP address via USB and WiFi. Try connecting via those IP addresses if all the rest fails.
163+
- If the containers are not being installed 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 it with ``docker ps -a``.
164+
165+
- If there is any issue running docker commands, make sure you are using ``sudo`` before the commands or having root access using: ``sudo su -r`` with password: ``fio``.
166+
167+
- If you cannot connect to the site when everything is running, you can double-check the X8's IP address. Run the command `ip -h address` in the **adb shell**. This will display the X8's IP address via USB and Wi-Fi®. Try connecting via those IP addresses if all the rest fails.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /