Developer IDE and server software setup guides

Here at XenForo, we like to keep our development environments up-to-date and as useful as possible, and from time to time we include some of our findings in our online documentation.

macos-debugging.jpg


Recently, we've published an easy setup guide for a Windows-based development environment and now we've added both a guide for building a very flexible macOS-based system and instructions for setting-up a similar multi-PHP deployment in Linux.

Multiple, simultaneous PHP versions​


The macOS and Linux installation guides bring the ability to simultaneously run multiple versions of PHP with Xdebug without having to switch the active version.

This can be invaluable for developers who want to build new code with PHP 8, but also want to maintain add-ons written for legacy software like XenForo 1.5.

macos-php-versions.png


Step debugging with Xdebug​


Furthermore, we've provided setup instructions to get step debugging working with Visual Studio Code and Xdebug. If you're not already using Xdebug as part of your PHP development system, it's time to start!

While the guides describe step-debugging in VS Code, the principles can be applied to PhpStorm or any other step-debug-capable IDE.

Video guides​


Both the Windows and macOS guides can be found in the XenForo 2 Dev Docs, and have accompanying videos to help you through the setup process.

macOS - multiple simultaneous PHP versions

How to install Apache, MariaDB, ElasticSearch, MailHog, ImageMagick and three versions of PHP to run simultaneously under macOS

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.
Note: I have updated the docs with an explanation of how to build the ImageMagick extension for PHP 8 manually, as the pecl install imagick command still doesn't work for PHP 8 - Kier

Ubuntu / Debian Linux - PHP 8.0, 7.4 and 5.6 at the same time

Configure Linux with three versions of PHP to run from a single Apache server at the same time

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.

Windows - super-easy setup

Install Apache, MySQL, PHP and Xdebug in just a few minutes

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.

Visual Studio Code - setup for PHP and Xdebug

Read the guide in the dev docs

linux-debugging.jpg
 
Last edited by a moderator:
Theoretically, the macOS multiple-PHP setup could work on Windows too, but I'm not sure that Windows has the same degree of support for php-fpm that macOS and Linux have. If I find a way to replicate the process on Windows, I'll post a new guide.

Linux should support the multiple-PHP option quite easily with a bit of config wrangling. Maybe I'll look into that if I have a spare moment too.
 
This is just what I needed, thank you!

One small mistake: about two-thirds of the way down you talk about creating info.php files, and then straight after you refer to the same files as index.php.
 
Thanks for the tutorial. Some other words:

MariaDB does not support NGRAM and it looks like their devs are extremely hesitate to devote any effort into supporting it.
This renders MariaDB hostile to small forums in CJK languages (because it won't support searching CJK strings).
(XenForo advanced search with ElasticSearch is mostly benefitial for giant forums, but not all forums are giant.)

It will be more helpful to either write this notification (to suggest CJK users to manually choose Oracle MySQL 8.x instead) or simply use MySQL in the guide. If MySQL5 query grammar is preferred, the last version of MySQL 5.x supports NGRAM.
 
Last edited:
It will be more helpful to either write this notification (to suggest CJK users to manually choose Oracle MySQL 8.x instead) or simply use MySQL in the guide. If MySQL5 query grammar is preferred, the last version of MySQL 5.x supports NGRAM.
That's useful information, thank you - I'll get that built into later versions of the guides at some point 👍🏼
 
Thanks for @ing me about that.

I also got an idea about how to enable SSL (https) with development servers on local intranets (for macOS and BSD distros).
XF 2.2 - Sign your localhost dev server to make it https-capable. | XenForo community

However, this utilizes the macOS built-in apache.
(I tried the same httpd config setup with homebrew apache2 and it simply doesn't work.)

Using macOS built-in apache means that every apache module has to be code-signed (even if using local certs made without paying a buck).
I verified that this instructive article can help users sign their homebrew PHP apache module (libphp.so for PHP 8.x):
How to future proof your apache modules in macOS by signing them with your own certificate authority (phusion.nl)
Once succeeded, one can always use this bash command to redo the codesign everytime homebrew updates the PHP:
(Please modify the "CERT COMPANY NAME" and "?.?.?" to the actual values used in your case prior to executing this command.)
Code:
codesign -s "CERT COMPANY NAME" --keychain ~/Library/Keychains/login.keychain-db /usr/local/Cellar/php/?.?.?/lib/httpd/modules/libphp.so
Here's the case on my side. You see no warning signs on the HTTPS lock icon (without having to read the Chinese UI texts).
1613476151283.png

1613476286793.png


FYI.
 
Nice work @ShikiSuen :)

The main reason I didn't use the built-in macOS Apache is that it's a little volatile in terms of retaining its configuration between OS upgrades, but in principle there's no other reason not to use it.

For what it's worth, the tutorials I've put together for macOS and Linux don't use PHP as a module at all, so the Homebrew php-fpm services shouldn't need to be signed in order to operate with the built-in Apache, but I'll double-check that...
 
The main reason I didn't use the built-in macOS Apache is that it's a little volatile in terms of retaining its configuration between OS upgrades, but in principle there's no other reason not to use it.

For what it's worth, the tutorials I've put together for macOS and Linux don't use PHP as a module at all, so the Homebrew php-fpm services shouldn't need to be signed in order to operate with the built-in Apache, but I'll double-check that...
Thanks for mentioning that. Till seeing your post I didn't notice that PHP-fpm can be used in Apache.
(Codesigning is exhausting, still.)
 
So I've just tested that theory, and it works. These are the config edits to use the built-in macOS Apache with Homebrew php-fpm versions:

Edit /private/etc/apache2/other/kier.conf and give it contents as follows, changing the path as applicable:

Apache config:
ServerName localhost

<VirtualHost *:80>
    DocumentRoot /Users/kier/Documents/www
    Timeout 3600
    <Directory "/Users/kier/Documents/www">
        Options Indexes MultiViews FollowSymLinks
        Require all granted
        AllowOverride all
        <FilesMatch \.php$>
            SetHandler "proxy:fcgi://localhost:9080#"
        </FilesMatch>
    </Directory>
</VirtualHost>

Now assuming that you already have your PHP versions installed through Homebrew as described in the tutorial, running sudo apachectl start will get the built-in macOS Apache running and passing off PHP requests to the listening php-fpm services.

Update: I forgot that I also enabled a bunch of modules in the main Apache configuration...

Edit /private/etc/apache2/httpd.conf and un-comment the following lines:

Apache config:
LoadModule proxy_module libexec/apache2/mod_proxy.so
LoadModule proxy_fcgi_module libexec/apache2/mod_proxy_fcgi.so

Then sudo apachectl restart
 
Last edited:
So I've just tested that theory, and it works. These are the config edits to use the built-in macOS Apache with Homebrew php-fpm versions:
Thanks. Looks like they don't work well in my case due to your preference of privilege settings in your server.

(I don't know whether rewrite mod is needed, but I initially left it enabled.)

I managed to get this work by only doing the two steps:

1) Enable the modules you said.

2) Directly set the filesmatch for PHP files from MIME to proxy (no sharps after the port number):
1613487250113.webp


Now it works on my computer.

P.S.: Unless the PHP-fpm runs on a standalone server, there is no need to change the sethandler domain to values other than 127.0.0.1:9000 default setting (which is the default setting used in PHP-fpm config file).

$ EOF.
 
Our XenForo dev environment is docker based with the following containers: nginx, MySQL, phpmyadmin(lazy about the CLI), PHP and redis. I feel like it is a touch easier then setting up system level installs and going full containerization is the way to go. However, your setup with Xdebug is pretty awesome. I may have some extra work to do tonight, lol.
 
Our XenForo dev environment is docker based with the following containers: nginx, MySQL, phpmyadmin(lazy about the CLI), PHP and redis. I feel like it is a touch easier then setting up system level installs and going full containerization is the way to go. However, your setup with Xdebug is pretty awesome. I may have some extra work to do tonight, lol.
Docker as a permanent development environment is a tricky subject - on the one hand, there's certainly something to be said for the ease of just running up a simple container that does everything you need, but conversely, there's a fairly sizeable overhead to having separate images for each version of PHP, the web server, the RDBS, Elasticsearch, Redis... Unless you're sharing this environment across a number of developers, or only using it for a short period of time, it seems to me that it's a fairly inefficient mechanism for rolling a generic development environment?
 
Back
Top Bottom