PHP7.2.x无openssl.so扩展问题求助
Hey there, let's work through this OpenSSL extension issue step by step for your setup. The core problem here is that system-level OpenSSL and PHP's OpenSSL extension are separate components—you've got the former installed, but the latter is missing or misconfigured. Let's fix this:
1. 先确认PHP 7.2的软件源(关键前提)
Debian Jessie 8.6's default repos don't include PHP 7.2 (it only ships with PHP 5.6), so you must have used a third-party repo like Dotdeb to install PHP 7.2. First, make sure your repo config is correct:
- Check files in
/etc/apt/sources.listor/etc/apt/sources.list.d/to confirm you have a valid PHP 7.2 repo for Jessie. For example, Dotdeb's repo lines should look like:deb http://packages.dotdeb.org jessie all deb-src http://packages.dotdeb.org jessie all - If you haven't added the repo's GPG key yet, run:
wget https://www.dotdeb.org/dotdeb.gpg apt-key add dotdeb.gpg - Update your repo cache:
apt-get update
2. 安装PHP 7.2专属的OpenSSL扩展
PHP's OpenSSL extension is a standalone package—system OpenSSL won't cover this. Install it with:
apt-get install php7.2-openssl
This command will automatically place openssl.so in the correct extension directory (/usr/lib/php/20170718/ as you checked) and configure your php.ini file, so you won't need to manually add the extension line (though leaving it in won't hurt if the path is correct).
3. 验证扩展是否生效
- For the CLI environment: Run
php -m | grep openssl—if you seeopensslprinted, the CLI side is working. - For Apache's PHP environment: Create a file named
info.phpin your web root (e.g.,/var/www/html/info.php) with this content:
Access this file via your browser, then search for "openssl". If you see a dedicated configuration block for OpenSSL, the Apache side is loading the extension correctly.<?php phpinfo(); ?>
4. Double-check the extension_dir path in php.ini
Sometimes an incorrect extension_dir setting can prevent PHP from finding the extension. Open /etc/php/7.2/apache2/php.ini and ensure this line is uncommented and points to the right directory:
extension_dir = "/usr/lib/php/20170718/"
Make sure the path matches exactly what you saw with your ls command.
5. Confirm Apache is using PHP 7.2
Verify that Apache has the PHP 7.2 module enabled:
a2query -m php7.2
If it returns php7.2 (enabled), you're good. If not, enable it with a2enmod php7.2 then restart Apache.
6. Check Apache error logs for clues
If you're still stuck, look at Apache's error log (/var/log/apache2/error.log)—it will have specific details about why the extension isn't loading, like path mismatches or permission issues. Use those logs to narrow down the problem.
内容的提问来源于stack exchange,提问作者zewOlF

