Ubuntu Trusty 14.04 EOL后安全安装PHP5.6的可行方案咨询
Hey there, let's figure out how to install PHP 5.6 on Ubuntu Trusty (14.04) now that it's reached EOL and the go-to ppa:ondrej/php no longer supports it. Here are some secure, practical solutions you can try:
1. Community-Maintained EOL System PPAs
Some community teams continue to offer limited support for EOL Ubuntu releases, including PHP 5.6. Look for reputable maintainers' PPAs (make sure to verify their credibility to avoid security risks) and follow these steps:
# First, update existing package lists (if your current sources are still accessible) sudo apt-get update # Add a trusted community-maintained PPA for EOL PHP versions sudo add-apt-repository ppa:trusted-eol-php-maintainer/php # Refresh package lists and install PHP 5.6 with desired extensions sudo apt-get update sudo apt-get install php5.6 php5.6-cli php5.6-fpm php5.6-mysql # Add other extensions as needed
Note: Always confirm the PPA maintainer's reputation before adding it—untrusted sources can introduce malware or unpatched vulnerabilities.
2. Compile PHP 5.6 from Source
This gives you full control over the build and allows you to apply any last-minute security patches (though keep in mind PHP 5.6 itself is EOL, so official security updates have stopped). Here's how to do it:
- Install build dependencies:
sudo apt-get install build-essential libxml2-dev libcurl4-openssl-dev libjpeg-dev libpng-dev libmysqlclient-dev libmcrypt-dev - Download the final stable release of PHP 5.6 (5.6.40 is the last official version):
wget https://www.php.net/distributions/php-5.6.40.tar.gz tar -xzf php-5.6.40.tar.gz cd php-5.6.40 - Configure the build with your required features (adjust flags based on your needs):
./configure --prefix=/usr/local/php5.6 --enable-cli --enable-fpm --with-mysql --with-curl --with-gd --with-mcrypt - Compile and install:
make -j$(nproc) # Use all available CPU cores for faster compilation sudo make install - Post-install setup:
Add/usr/local/php5.6/binto your systemPATH(edit~/.bashrcor/etc/profile), then configure PHP-FPM as a system service using a custom init script (you can reference the default PHP-FPM config structure for guidance).
3. Containerize with Docker
Docker is a great way to isolate PHP 5.6 from your EOL system, avoiding conflicts and leveraging pre-built images. Here's a quick setup:
- Install a compatible Docker version on Trusty:
sudo apt-get install docker.io - Pull a PHP 5.6 image (look for well-maintained images, even if official ones are no longer updated):
docker pull php:5.6-fpm - Run the container, mounting your application code directory:
docker run -d -v /path/to/your/app:/var/www/html -p 9000:9000 php:5.6-fpm
Pro tip: If you need additional extensions, create a custom Dockerfile based on the base image to install them—this keeps your setup reproducible.
4. Migrate to a Supported Ubuntu Version (Long-Term Solution)
While this isn't a direct installation fix, it's the most secure option in the long run. Ubuntu 14.04 has no official security updates left, so even if you get PHP 5.6 running, your system's other components will remain vulnerable. Consider migrating to Ubuntu 18.04 LTS (or newer) where ppa:ondrej/php still supports PHP 5.6, and you'll get ongoing security patches for the OS itself.
内容的提问来源于stack exchange,提问作者sakhunzai

