Running WordPress on OpenShift with MariaDB

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.

Asad Hanif

??DevOps Engineer | MLOps Practitioner | LLMOps | Kubernetes | AWS | Azure | Python

1 年

Masha Allah excellent work

Sheikh Hassaan Bin Nadeem

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?

回复
Babar Zahoor

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 ??

Muhammad Arsalan

?? 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.

Irfan Ali babbar

Addministation, Al artificial intelligence student.softwer dev

1 年

Nice to hear About it

要查看或添加评论,请登录

HINA NASEER AHMED的更多文章

  • Taking My First Steps with Red Hat OpenShift!

    Taking My First Steps with Red Hat OpenShift!

    Excited to share that I've officially embarked on my Red Hat OpenShift adventure! Today, I signed up for a Red Hat…

    17 条评论

社区洞察

其他会员也浏览了