setup-php supports self-hosted runners in addition to GitHub-hosted runners. This page covers supported operating systems, runner configuration, containerized setups, and local testing.
Supported operating systems
The following operating systems are supported on self-hosted runners:| Host OS | YAML workflow label |
|---|---|
| Ubuntu 24.04 | self-hosted or Linux |
| Ubuntu 22.04 | self-hosted or Linux |
| Debian 13 | self-hosted or Linux |
| Debian 12 | self-hosted or Linux |
| Debian 11 | self-hosted or Linux |
| Windows 7 and newer | self-hosted or Windows |
| Windows Server 2012 R2 and newer | self-hosted or Windows |
| macOS Tahoe 26.x (x86_64/arm64) | self-hosted or macOS |
| macOS Sequoia 15.x (x86_64/arm64) | self-hosted or macOS |
| macOS Sonoma 14.x (x86_64/arm64) | self-hosted or macOS |
Operating systems based on the supported Ubuntu and Debian versions are also supported on a best-effort basis. PHP 5.6 to PHP 8.6 can be set up on self-hosted runners.
Setting the runner environment variable
Set therunner environment variable to self-hosted when using self-hosted runners. This tells setup-php to apply self-hosted-specific behaviour during setup.
Containerized self-hosted runner setup
Running the GitHub Actions runner inside a container isolates it from the host OS and makes it easier to reproduce environments. Follow the appropriate guide for your host OS:Linux
Guide for running a containerized self-hosted runner on a Linux host.
Windows
Guide for running a containerized self-hosted runner on a Windows host.
Running directly on the host OS
If you prefer to run the Actions runner directly on the host machine or in a virtual machine rather than in a container, review the requirements guide before registering your runner. The guide covers required packages, permissions, and system configuration for each supported OS.Service containers
Complete example with matrix
The following workflow sets up multiple PHP versions on a self-hosted runner using a matrix strategy:Best practices
One runner per server instance
One runner per server instance
Do not register multiple self-hosted runners on the same server instance. Parallel workflow jobs will conflict with each other during PHP setup, leading to race conditions and unpredictable failures.
Isolate runners from other environments
Isolate runners from other environments
Do not run self-hosted runners alongside your development environment or on a production server. A workflow step with sufficient permissions could inadvertently modify files or services on the host.
Use distinct runner labels
Use distinct runner labels
Avoid using labels on your self-hosted runners that match GitHub-hosted runner labels (for example,
ubuntu-latest, windows-latest). Ambiguous labels can cause workflows intended for GitHub-hosted runners to be dispatched to your self-hosted runner instead.Local testing with nektos/act
nektos/act lets you run your GitHub Actions workflows locally. Use shivammathur/node Docker images as the container for act to get an environment compatible with setup-php.
Choose the image tag that matches the runs-on value in your workflow: