无法安装PHP的intl扩展:编译提示php_smart_str.h文件缺失求助
Hey there, I’ve run into this exact error before—let’s walk through how to fix it step by step. The missing php_smart_str.h file is part of PHP’s standard extension development headers, so the issue usually boils down to missing dependencies or incorrect path configuration.
Step 1: Install Required System Dependencies
First, make sure you have the necessary development packages installed, both for PHP itself and the ICU library (which the intl extension relies on):
For Debian/Ubuntu-based systems:
sudo apt update sudo apt install php-dev libicu-dev
Note: If you’re using a specific PHP version (like 8.1), use php8.1-dev instead of php-dev.
For RHEL/CentOS/Rocky Linux systems:
sudo dnf install php-devel libicu-devel
For older RHEL/CentOS versions, replace dnf with yum.
Step 2: Reinstall the intl Extension
Once the dependencies are in place, try running the PECL install command again:
sudo pecl install intl
Step 3: If the Error Persists—Manually Specify PHP Paths
If you still see the missing header error, it might be because PECL can’t locate your PHP development files. Let’s fix that:
- First, find where
php_smart_str.his located on your system:
find /usr -name php_smart_str.h
You’ll get a path like /usr/include/php/ext/standard/php_smart_str.h.
- Use that path to specify the include directory when installing:
sudo pecl install --with-include-dir=/usr/include/php/ext/standard/ intl
Alternatively, you can point PECL to your system’s php-config binary (which holds all the correct path info):
sudo pecl install intl --with-php-config=$(which php-config)
Step 4: Verify the Installation
After a successful install, don’t forget to enable the extension in your PHP config. Add this line to your php.ini file (or a dedicated conf file in /etc/php/[version]/mods-available/):
extension=intl.so
Then restart your web server or PHP-FPM to apply the changes.
内容的提问来源于stack exchange,提问作者Sory

