Is CircleCI blocked by PHP Mirrors? I am getting 503 when installing the docker-php-ext-install.
@circleci-community please help in understanding that I am able to call the URL https://www.php.net/distributions/php-8.3.30.tar.xz but in CircleCI job it is giving errors.
^@^@curl: (22) The requested URL returned error: 503 /usr/local/bin/docker-php-ext-install: line 19: cd: /usr/src/php/ext: No such file or directory Exited with code exit status 1
2 Likes
RossW
March 3, 2026, 9:32am
2
+1 on this. We are using the cimg/php:7.4 image (lots of back-compat testing) and get the same problem.
Our job runs docker-php-ext-install zip
The docker-php-ext-install script in the image runs docker-php-source extract, which should be doing curl -fsSL -o php.tar.xz https://www.php.net/distributions/php-7.4.33.tar.xz
Running the curl command locally works fine. But we are seeing the 503 error in CircleCI.
We also suspect that CircleCI has been blocked by php.net
RossW
March 3, 2026, 9:49am
3
+1.
I found this issue too.
Tried switching images doesn’t help.
cimg/php:8.4.18-node
cimg/php:8.4-node
Also tried switching resource_class doesn’t help too.
The error:
curl: (22) The requested URL returned error: 503
/usr/local/bin/docker-php-ext-configure: line 19: cd: /usr/src/php/ext: No such file or directory
I ended up by compiling from scratch using the custom script. Sharing here if someone needs a quick solution.
#!/usr/bin/env bash
set -euo pipefail
echo "PHP_VERSION=$(php -r 'echo PHP_VERSION;')"
# If source already exists (e.g., restored from cache), stop here.
if [ -d /usr/src/php/ext ]; then
echo "/usr/src/php/ext already present, skipping download"
exit 0
fi
# Keep a copy of the original script once per job container
if [ ! -f /usr/local/bin/docker-php-source.orig ]; then
sudo cp /usr/local/bin/docker-php-source /usr/local/bin/docker-php-source.orig
fi
# Install wrapper. This is in a repo file, so CircleCI config parsing won't care about the heredoc.
sudo tee /usr/local/bin/docker-php-source >/dev/null <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
cmd="${1:-}"
PHP_VER="$(php -r "echo PHP_VERSION;")"
PRIMARY="https://www.php.net/distributions/php-${PHP_VER}.tar.xz"
FALLBACK1="https://www.php.net/get/php-${PHP_VER}.tar.xz/from/this/mirror"
FALLBACK2="https://downloads.php.net/~phpweb/php-${PHP_VER}.tar.xz"
FALLBACK3="https://github.com/php/php-src/archive/refs/tags/php-${PHP_VER}.tar.gz"
download() {
local url="${1:?missing url}"
echo "Downloading: ${url}"
rm -f /tmp/php.tar.xz /tmp/php.tar.gz
if echo "${url}" | grep -qE '\.tar\.xz($|\?)'; then
curl -4 -fL --retry 8 --retry-all-errors --retry-delay 2 -o /tmp/php.tar.xz "${url}"
else
curl -4 -fL --retry 8 --retry-all-errors --retry-delay 2 -o /tmp/php.tar.gz "${url}"
fi
}
extract_source() {
sudo rm -rf /usr/src/php
sudo mkdir -p /usr/src/php
if [ -f /tmp/php.tar.xz ]; then
sudo tar -xJf /tmp/php.tar.xz -C /usr/src/php --strip-components=1
elif [ -f /tmp/php.tar.gz ]; then
sudo tar -xzf /tmp/php.tar.gz -C /usr/src/php --strip-components=1
else
echo "No PHP source archive found in /tmp"
exit 1
fi
test -d /usr/src/php/ext
}
case "${cmd}" in
extract)
echo "docker-php-source extract: PHP_VER=${PHP_VER}"
echo "Trying: ${PRIMARY}"
echo "Fallback: ${FALLBACK1}"
echo "Fallback: ${FALLBACK2}"
echo "Fallback: ${FALLBACK3}"
if [ -d /usr/src/php/ext ]; then
echo "/usr/src/php already present"
exit 0
fi
download "${PRIMARY}" \
|| download "${FALLBACK1}" \
|| download "${FALLBACK2}" \
|| download "${FALLBACK3}"
extract_source
;;
delete)
sudo rm -rf /usr/src/php /tmp/php.tar.xz /tmp/php.tar.gz || true
;;
*)
exec /usr/local/bin/docker-php-source.orig "$@"
;;
esac
EOF
sudo chmod +x /usr/local/bin/docker-php-source
# Force extraction now so failures are explicit
docker-php-source extract
This issue shall be fixed with this PR
main ← cleverrocks:fix/docker-php-source-fallback-urls
opened 02:56PM - 04 Mar 26 UTC
Add fallback URLs and retries so docker-php-ext-install does not fail when the p… rimary PHP source URL is unavailable.
**Checklist note:** Changes are in `docker-php-scripts/docker-php-source` (the script that is copied into the image via the template). I did not change `Dockerfile.template` or any generated Dockerfiles.
---
# Description
`docker-php-ext-install` can fail when php.net returns 503 or is unavailable, leading to “cd: /usr/src/php/ext: No such file or directory” because `docker-php-source extract` never succeeded.
# Reasons
Add multiple fallback URLs (php.net distributions, mirror, downloads.php.net, GitHub php-src) so one failing endpoint doesn’t break the build.
- Add curl retries (2 retries, 2s delay) for transient errors.
- Use `php -r 'echo PHP_VERSION'` for version detection.
- Support both .tar.xz (php.net) and .tar.gz (GitHub) in docker-php-source.
# Checklist
- Change is in `docker-php-scripts/docker-php-source` (script shipped with the image), not in generated Dockerfiles.
- No manual edits to auto-generated files.
- Follows CONTRIBUTING guidelines.
- [ ] I have made changes to the `Dockerfile.template` file only
- [x] I have not made any manual changes to automatically generated files
- [x] My PR follows best practices as described in the [contributing guidelines](CONTRIBUTING)
- [ ] (Optional, but recommended) My commits are [signed](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits)
RossW
March 5, 2026, 9:48am
8
Awesome work, @cleverrocks . Thank you.