Categories
Daily Blog Linux WordPress

Installing WordPress Development Environments in Manjaro.

Before we do anything, let’s make sure you have enough inotify watchers configured in your Manjaro installation. Type this into your terminal:

cat /proc/sys/fs/inotify/max_user_watches

If the number is much higher than 16384 (Manjaro’s default), you’re probably good, if not, check out my article “Increasing Inotify Watchers is a Must after Installing Manjaro” to boost it up to 524288.


Coding Setup for WordPress

A few years ago, I took courses from Tonya Mork’s knowthecode.io site, and the recommended Mac development environment setup is mostly recreatable in Manjaro.

Git comes installed out of the box, and obviously you’re going to want to get Git configured early on. (Personally, I’m trying to host my own stuff at Gitlab instead of Github. I don’t need more Microsoft in my life.)

TL:DR – I’m using Local by Flywheel and PHP Storm. Nothing magic. Desktop Linux is a great option in 2020.

Package Managers, Helpers, etc.

PHP, Composer, npm, node, and gulp

I searched for “npm” in Pamac and installed it from there. It will include node.js and a bunch of other dependencies, so obviously click “yes” when it asks.

To make sure npm works, let’s install gulp globally, which is something I’ll be using with my WordPress theme builds. Type this into the terminal:

sudo npm install --global gulp-cli

I also installed php and composer right from the pamac interface. You will usually be developing in some sort of container that is similar to your production environment, which brings us to…

docker

Next, I installed docker and docker-compose from pamac. After, type the word docker into your terminal and if a bunch of stuff comes up, it installed correctly.

I, however…

I Had an Oopsie?

This section isn’t necessary unless you have this problem, but I just thought I’d share what happened as I was installing and writing this. Skip to adding your user to the docker group.

For whatever reason, on my next restart, I tried to do something with docker, and would get a messages that the docker daemon wasn’t running. Umm…dang.

I found the command to start the docker daemon manually:

sudo dockerd

and I also found a way to configure docker to start on boot, which solved the problem I was having above:

sudo sysemctl enable docker

In the dozens of times I’ve installed Manjaro, I’ve never had this problem with Docker before. It’s possible I missed the next step…?

Adding Your $USER to the docker Group.

The docs recommend adding yourself to the group “docker” to run docker commands without sudo. To check all of the groups on my system I typed less /etc/group into the terminal. It was a long list and docker was at the bottom. So I used the following command to add myself to the group:

sudo usermod -aG docker $USER

After logging out and in, and typing groups in the command line, you’ll see a list of groups that your user belongs to, and docker will be on there.

(Adding my user to groups is also something I’m going to do when setting up Jack for audio production on my workstation.)

A few relevant Docker docs:
https://wiki.archlinux.org/index.php/Docker
https://docs.docker.com/install/linux/linux-postinstall/#configure-docker-to-start-on-boot
https://docs.docker.com/config/daemon/


WordPress Dev Environments

On Mac, I used MAMP for years, and then Local by Flywheel. On Linux, at first, I tried Xampp for a while, then I switched to VVV, then WP Local Docker by 10Up. Just a few months ago, Local by Flywheel was finally ported to Linux! Here are some notes and links for setting these up.

Local by Flywheel

I’ve only begun testing this, but it’s so simple to use, and seems much faster than the version I used years ago on a mac. I’m going to make it my day to day environment for a while, and hopefully it works out. If not, I have no problem going back to WP Local Docker, which I’m still happy with.

I installed Local by Flywheel from the AUR (Arch User Repository), and it failed, at first. I realized I was missing a couple of dependencies.

Installing Dependencies

When you are installing something from the AUR, you’re going to want to pull up its page and see the comments and notes. The Local by Flywheel AUR page helped solve my issues, when I realized the package I was installing was asking me if I wanted to install any dependencies. Luckily, those are also listed on the AUR page.

Dependencies: Search and install/build the following apps one by one – ncurses5-compat-libs (AUR),
nettle6 (AUR)
numatcl
rpm-tools

(check to see if any other dependencies listed are mising from your machine).

After those dependencies were in place, I had no problem installing Local by Flwheel from the AUR.

Permissions

The AUR page contains a pinned comment that says:

“You’d need to do: sudo chown root:root /opt/Local/chrome-sandbox and: sudo chmod 4755 /opt/Local/chrome-sandbox for it to work.”

Might as well hit f12 and run those.

First Site Fails for me – Permissions thing?

I hit the super key and type “Local”, click the icon, and get through the prompts and try to make my first site. On both my workstation and on my Thinkpad, I had problems with my first site. There seemed to be a password popup to give Local some root permission for localhosting stuff, but as soon as it becomes visible you get an error. Try to find that dialogue box and get that password in there anyway, and the rest of your sites will work fine. It’s a one time thing.

So far, liking Local by Flywheel, and officially making it my day to day now.

WP Local Docker by 10Up

This is a comand line docker environment that gets close to the feature set of Local, and was indespensible to me while Local by Flywheel was unavailable for Linux. The mailcatcher was a difference maker for me the few times I used it.

Since we set up Docker above, installation for WP Local Docker went smoothly for me by following the docs.

Just remember that if you’re going to switch back and forth between any of these environments, you should probably log out of Manjaro and back in, otherwise they might be fighting for hosting redirects.

VVV

The official way to test WordPress plugins and themes and to contribute to WordPress core development is this environment called Varying Vagrant Vagrants.

I used it for a few months and it felt pretty slow, but I know I’ll be testing things on here at some point.

Install vagrant from pamac and then use the following line to install vagrant hosts updater:

vagrant plugin install vagrant-hostsupdater

Now we get to install Virtual Box.

First, had a failure here because I forgot to enable virtualization on my brand new Ryzen computer. So I booted into the bios hitting f12 when seeing the splash screen and went to M.I.T -> Advanced Frequency Settings -> Advanced CPU Core Settings -> SVM Mode and turned on AMD-V. (You may have to enable virtualization on Intel computers, too. Check your bios).

Next type this into a terminal to see which Linux kernel you are running:

mhwd-kernel -li

I was at linux55, so I installed virtualbox and linux55-virtualbox-host-modules (this number should match your kernal version.). Restarted and installed virtualbox-ext-oracle.

Add yourself to the vboxusers group with

sudo gpasswd -a $USER vboxusers

Now VVV is ready to install by following their docs.

I just realized that I used two different commands in this article to add a #USER to groups. They both work, but Usermod -aG vs gpasswd -a as a best practice can fill you in on the differences.

$USER is a variable for the user you are logged in as, if you iddn’t know.

Xampp

This has its own installer you can download right from its site. I feel like this has the least features of all of the WordPress development options, but it’s a no frills, basic package that gives you the minimum software stack you need to run WP. One issue for me was permissions, since your sites by default exist in the /opt/lampp/htdocs/ folder, and not your user folders. Nothing against Xampp, I’ll fire it up to practice PHP tutorials, for sure.

Code Editors

Another deeply personal choice. Editors like Sublime Text, Atom, and VS Code (Microsoft, tho…) are all available from various repositories on Manjaro. And mentioned above, Manjaro KDE comes with the Kate text editor, which I’ll gladly open up config files with.

PHP Storm

I’m newish to PHP, and WordPress, and need an IDE right now. I tested PHPStorm a year ago on , and it worked great. Obviously I’m finding even better performance on my 2020 Rzyen workstation.

JetBrains, the makers of PHPStorm, have one of the best installers on Linux with their Toolbox app, which allows you to install and manage your JetBrains apps really easily.

Just download Toolbox .tar.gz from that page, go to your Downloads folder and extract it, and double click.

Question for Manjaro KDE Pros – am I missing any KDE / Manjaro specific gui integrations by installing PHPStorm from the JetBrains Toolbox App? Would PHPStorm from the AUR be better in any way?

This is NOT free, unlike the editors I mentioned in the intro to this section. I paid like $90 for a year of PHP Storm, and what’s cool is the price goes down every year if you renew it. I’m very happy to support companies who support Linux!


That’s all for today. I was working on a theme for this site for a while, but now I’m having trouble with the build process. Hopefully when I get that ironed out I can jump full on into looking for clients to build WordPress sites for. Looking for the right clients!

Leave a Reply

Your email address will not be published. Required fields are marked *