<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>wctaiwan</title><link href="https://wctaiwan.com/blog/" rel="alternate"></link><link href="https://wctaiwan.com/blog/feeds/all.atom.xml" rel="self"></link><id>https://wctaiwan.com/blog/</id><updated>2021-11-12T00:00:00-08:00</updated><entry><title>Setting up a MediaWiki development environment on M1 Macs using Multipass</title><link href="https://wctaiwan.com/blog/multipass-mediawiki.html" rel="alternate"></link><published>2021-11-12T00:00:00-08:00</published><updated>2021-11-12T00:00:00-08:00</updated><author><name>wctaiwan</name></author><id>tag:wctaiwan.com,2021-11-12:/blog/multipass-mediawiki.html</id><summary type="html">&lt;p&gt;Over the past week, I spent some time figuring out how to set up a MediaWiki development environment on my laptop. Here were some things I learned:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;MediaWiki-Docker (using the included &lt;code&gt;docker-compose.yaml&lt;/code&gt;) doesn't work, as the images specified in &lt;code&gt;docker-compose.yaml&lt;/code&gt; are built for x86, not ARM.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://podman.io/"&gt;Podman&lt;/a&gt; works …&lt;/li&gt;&lt;/ol&gt;</summary><content type="html">&lt;p&gt;Over the past week, I spent some time figuring out how to set up a MediaWiki development environment on my laptop. Here were some things I learned:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;MediaWiki-Docker (using the included &lt;code&gt;docker-compose.yaml&lt;/code&gt;) doesn't work, as the images specified in &lt;code&gt;docker-compose.yaml&lt;/code&gt; are built for x86, not ARM.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://podman.io/"&gt;Podman&lt;/a&gt; works surprisingly well on macOS (installed from Homebrew, and using the built-in &lt;code&gt;podman machine&lt;/code&gt;). I was even able to get docker-compose to work by following the instructions in &lt;a href="https://news.ycombinator.com/item?id=28464897"&gt;this HN comment&lt;/a&gt;, but ultimately there were two blockers:&lt;ol&gt;
&lt;li&gt;The issue with image architectures above&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/containers/podman/issues/8016"&gt;Bind mounts are unsupported&lt;/a&gt; as of the time of writing, which prevents using a checkout of MediawWiki on the host in the VM/container&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In the end, I ended up using &lt;a href="https://multipass.run/"&gt;Multipass&lt;/a&gt;, which provides a quick way to spin up a headless Ubuntu VM across multiple platforms. Unlike with Podman, bind mounts &lt;em&gt;are&lt;/em&gt; supported, and so I was able to clone MediaWiki on the host and map the checkout into the VM, which makes it much easier to develop on the host, and use the VM purely as a web server.&lt;/p&gt;
&lt;p&gt;One thing to note with this process is that I ran into errors caused by file permission issues when I tried to run &lt;a href="https://getcomposer.org/"&gt;Composer&lt;/a&gt; from inside the VM to install dependencies, likely due to the interaction between &lt;code&gt;sshfs&lt;/code&gt; and file ownership on the host and in the VM (since this would be run from inside the bind mount). The workaround was to install PHP (using Homebrew) on the host system, and manage dependencies from the host as well.&lt;/p&gt;
&lt;p&gt;Below are the high-level steps I took:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install Multipass using &lt;code&gt;brew install --cask multipass&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Create an Ubuntu VM using &lt;code&gt;multipass launch&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;multipass shell&lt;/code&gt; to open an SSH session into the VM, and install Apache, PHP, MariaDB, &lt;code&gt;php-fpm&lt;/code&gt; and &lt;code&gt;php-mysql&lt;/code&gt; using &lt;code&gt;apt&lt;/code&gt;. Note that you might also need to manually install some of the PHP extensions listed &lt;a href="https://www.mediawiki.org/wiki/Manual:Installation_requirements#PHP"&gt;here&lt;/a&gt; when prompted by the install script later.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;sudo mysql_secure_installation&lt;/code&gt; inside the VM to configure MariaDB, and set up a database and user for MediaWiki.&lt;/li&gt;
&lt;li&gt;Sanity check that the web server works at this point: Run &lt;code&gt;multipass ls&lt;/code&gt; and go to the IP of the VM in a web browser. It should show the default page for Apache.&lt;/li&gt;
&lt;li&gt;Install PHP on the host using &lt;code&gt;brew install php&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Clone MediaWiki on the host by following the instructions &lt;a href="https://www.mediawiki.org/wiki/Download_from_Git#Download_for_development"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;On the host, run Composer inside the MediaWiki checkout by following the instructions &lt;a href="https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Mount the MediaWiki checkout in the VM at &lt;code&gt;/var/www/html/w&lt;/code&gt; using &lt;code&gt;multipass mount&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Navigate to &lt;code&gt;http://&amp;lt;VM_IP&amp;gt;/w/&lt;/code&gt; and follow the instructions.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;With this setup, the bind mount essentially allows Apache in the VM to use the MediaWiki checkout, but all of the actual development would take place on the host.&lt;/p&gt;</content><category term="misc"></category></entry></feed>