Running WordPress Locally on Android (Without Losing Sanity)




The Beginning

There are two types of people in the world: those who spin up WordPress with a click on cPanel, and those who see a mountain and climb it anyway. Guess which one I am?

This story begins with me, a solar-powered, Android-based dev-in-progress with a Samsung phone, a Lenovo tablet, and a fever dream. My dream was to run full WordPress locally without touching a laptop. This happened because earlier I watched a YouTube tutorial for custom WordPress theme creation and I was bummed about not having access to a PC to try it out.

The guy suggested Local and XAMPP, and I snorted because I already knew what I’d be attempting later that day.

Termux? Installed. Acode? Bless its dear tabs. Sanity? Fragile. On y va! (What? I did French in school.)

Regret

At some point, I did ask myself, “Should I even be doing this thing?” But by then I had already installed Apache, PHP, and MariaDB inside Termux. Literally no one turns back after a 500MB-ish update.

The Port of Eternal Suffering

I tried running:

php -S localhost:8000

Like a good dev. It, of course, tried to frustrate me with: "Address already in use." Apparently, the port was haunted by a previous life, because what do you mean already in use? Who is using it? I know it's not me, Termux.

That’s when I realized I needed a bash script that would find a free port, like a dating app for localhost. So I made one. Ha.

MariaDB (aka Rethinking My Choices)

I tried:

mysql_install_db

And Termux wasn't having it. “That’s deprecated!”

I feel like Termux is trying to embody an ex-boyfriend because the communication issues we have are wild. So I tried again with:

mariadb-install-db

I thought maybe this time I'd win. I didn’t.

I ran:

mariadbd-safe &

Like a boss. I logged in. Then it kicked me out. Then I begged my ancestors. I discovered that I had created a password and it was being enforced. I typed the password. Then it worked. I called it relationship growth.

WordPress, Sweet WordPress

I downloaded WordPress manually (because wget was not getting a thing with my network). I created a wp-config.php file. Inside it, I tentatively tried 127.0.0.1 like it was a love letter to localhost, since the other ports were haunted by who knows what.

And after a bit, WordPress opened on my browser. Locally. On a phone. I screamed.

Then I remembered I had to do it all over again on my tablet... my left eye started twitching.

The Bash Script of Hope

Rather than ugly cry, I made a script... yeah, it’s becoming a thing. I call it conflict avoidance. Then I zipped the script. Then I wrote this blog post. You, dear reader, can download everything I used here. No gatekeeping. No pain (well, maybe less pain).

What’s Next?

Well, I’m starting on my own custom WordPress theme based on _s (underscores). It’s going to be simple, clean, and built entirely from my tablet and phone. Expect CSS, PHP, and some crying.

TL;DR:

  • You can run WordPress locally on an Android device using Termux.
  • It’s not for the faint of heart.
  • I wrote scripts so you don’t suffer.
  • You're welcome.

Comments

  1. Well, heck, I don't understand half the stuff I read, but I could feel the vibe: the struggle, the "I don't know what the hell I'm doing, but I will keep doing it until I figure it out" attitude on the whole of it and I love it.

    ReplyDelete

Post a Comment