Drupal 8项目用Composer下载Drush遇Packages.json SSL超时问题求助
Hey there, I’ve dealt with this exact SSL timeout issue a few times when working with Drupal and Composer, so let’s walk through some practical fixes to get Drush installed smoothly:
Update Composer to the latest version
Outdated Composer versions often have SSL-related bugs or compatibility issues. Run this command to update your global Composer install:composer self-updateIf you run into permission issues on Linux/macOS, prepend
sudo:sudo composer self-updateIncrease Composer’s timeout limit
The default timeout might be too short for slow network connections. Try temporarily increasing it when running the Drush install command:composer require drush/drush --timeout=300The
300here sets a 5-minute timeout—adjust it higher if needed. You can also set this permanently in your global Composer config by running:composer config -g process-timeout 300Verify and update your system’s CA certificates
Missing or expired root CA certificates can break SSL verification. Here’s how to refresh them on common systems:- For Debian/Ubuntu:
sudo apt-get update && sudo apt-get install --reinstall ca-certificates - For CentOS/RHEL:
sudo yum update ca-certificates - For macOS: Use Homebrew to update OpenSSL (which includes up-to-date certificates):
brew install openssl
- For Debian/Ubuntu:
Check for network proxies or firewalls
If you’re on a corporate network, a proxy might be interfering with Composer’s SSL connections. To configure a proxy (replaceproxy:portwith your actual details):composer config -g http.proxy http://proxy:port composer config -g https.proxy https://proxy:portIf you don’t need a proxy, clear any existing settings with:
composer config -g --unset http.proxy composer config -g --unset https.proxyTry a different Packagist mirror
Slow access to the default Packagist repository can cause timeouts. Switch to a faster mirror temporarily:composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/After installing Drush, you can switch back to the official repo if you want:
composer config -g repo.packagist composer https://packagist.orgTemporarily disable SSL validation (last resort)
This isn’t recommended for long-term use due to security risks, but it can help confirm if the issue is SSL-related. Run:composer require drush/drush --insecureIf this works, go back and fix your certificate or network settings instead of relying on this workaround.
Start with updating Composer first—it’s the quickest fix for most SSL-related glitches. If that doesn’t work, work through the other steps one by one, and you should have Drush up and running in no time.
内容的提问来源于stack exchange,提问作者clestcruz

