Running WordPress on OpenShift with MariaDB
Step 1: Log in from the CLI
Open your CMD/Terminal and paste the login credentials. The command consists of the oc login + the server URL attached with the live session generated token.
You are now successfully logged in to the OpenShift Container Platform server using the oc CLI. It shows a list of the available OpenShift projects.
Step 2: Create a project
Create a project to host your deployments and resources.
From CMD/terminal, run the following command:
oc new-project wordpress
Step 3: Deploy your database and your WordPress app on OpenShift
After creating a project, you need to deploy your WordPress application.
First, you need to create the back-end database instance, which is in our case MariaDB. From the CMD/terminal, run the following command:
oc new-app mariadb-ephemeral
Note: MariaDB is not using persistent storage. So, any data stored is lost when pods are destroyed. Instead, you use a sample database in this tutorial for testing purposes.
Take a note or your MariaDB-generated information: MariaDB connection user name, MariaDB connection password, and MariaDB database name. For the DB host, use mariadb.
Because you are going to deploy WordPress, build your project on Apache with a PHP image.
From the CMD/terminal run the following command:
oc new-app php~https://github.com/wordpress/wordpress
You can track the deployment by viewing its logs:
领英推荐
oc logs -f dc/wordpress
After you successfully deployed WordPress, you need to access it. You expose it as a service using the following command:
oc expose svc/wordpress
Next, query the service route for the host URL that is generated. Run the following command:
oc get routes
Copy the generated host name from your terminal and paste it in any browser. You should see the welcome screen of the deployed WordPress application, waiting for the database configurations to complete its setup. It should look like the following screen captu
From the WordPress dashboard, you can start building your own WordPress website:
Now, you have deployed your two resources under one project: MariaDB and WordPress.
You can get a visual view by going back to your Red Hat OpenShift console web user interface. Click Refresh and you successfully see your newly created project listed on the My Projects tab, including the two created resources.
Use the database information you previously created to complete the WordPress installation. Complete the information needed and click Install WordPress.
After successfully setting up WordPress, the login screen of WordPress opens. Use the user name and password set earlier and lo
In the top left corner, click the website name with the home icon. Click View Site to preview your website. The following screen captures shows a built WordPress website deployed:
From the WordPress dashboard, you can start building your own WordPress website:
In the top left corner, click the website name with the home icon. Click View Site to preview your website. The following screen captures shows a built WordPress website deployed:
Summary
Congratulations! You learned how to deploy your WordPress application connected to a MariaDB instance from inside a container, using Red Hat OpenShift.
??DevOps Engineer | MLOps Practitioner | LLMOps | Kubernetes | AWS | Azure | Python
1 年Masha Allah excellent work
x Tech BA @ KTrade | Products ? Love Helping teams Launch and Scale ?? | DevOps | Cloud | AI | Cyber Enthusiast
1 年Informative! But isn't it easier to do the same thing by writing a yaml file on docker compose? Why should we use open shift in this case instead of docker compose?
Co-Founder and CTO at Fusion AI & CloudDev Technologies | Board Member KPITB | OpenRiyadh | Founder OSFP | Digital Transformation | ex Systems Limited | ex Oxfam | ex BoD ISOC Pakistan | AI Cloud Architect
1 年Good work ??
?? Front-End Developer | Learning Agentic AI | Next.js, React.js, TypeScript, Headless CMS | ?? Student at Govt. of Pakistan Generative AI Initiative
1 年Thanks for sharing. Congratulations, Hina Naseer Ahmed! This sounds like an insightful article. Looking forward to reading it and learning more about deploying WordPress on OpenShift.
Addministation, Al artificial intelligence student.softwer dev
1 年Nice to hear About it