Manually install the intl extension of php7.4 under Centos7

PHP intl is an internationalization extension, which is a wrapper for the ICU library. So you need to install the ICU library before installing the PHP intl extension. Here's how to manually install the PHP intl extension.

PHP It is an internationalization extension, which is a wrapper of the ICU library. So you need to install the ICU library before installing the PHP intl extension.
What is ICU?
ICU is a mature, widely used set of C/C++ and Java libraries that provide Unicode and globalization support for software applications. ICU is widely portable, giving applications the same results on all platforms and between C/C++ and Java software.
ICU is distributed under a non-restrictive open source license suitable for use with commercial software as well as other open source or free software.

Here are some highlights of the services provided by the ICU:

Code Page Conversion: Convert text data back and forth between Unicode and nearly any other character set or encoding. ICU's conversion tables are based on decades of character set data collected by IBM and are the most complete available anywhere.

Collation: Compare strings according to the conventions and standards of a specific language, region, or country. ICU's collations are based on the Unicode Collation Algorithm and locale-specific comparison rules from the Common Locale Data Repository, a comprehensive source of such data.

Formatting: Formats numbers, dates, times, and monetary amounts according to the format of the selected locale. This includes translating the names of the months and days into the selected language, choosing appropriate abbreviations, ordering fields correctly, etc. This data also comes from the common locale data repository.

Time calculation: In addition to the traditional Gregorian calendar, it also provides multiple types of calendars. It provides a complete set of time zone calculation APIs.

Unicode Support: ICU closely tracks the Unicode standard and provides easy access to all of the many Unicode character properties, Unicode normalization, case conversion, and other basic operations specified by the Unicode standard.

Regular Expressions: ICU's regular expressions fully support Unicode while providing very competitive performance.

Bidi: Supports handling of mixed text containing left-to-right (English) and right-to-left (Arabic or Hebrew) data.

Text Boundaries: Find the location of a word, sentence, paragraph within a range of text, or determine where appropriate for line breaks when displaying text.
And much more. See the ICU User Guide for details.

First download the ICU software package. For the latest version, visit the ICU official website. The website address ishttp://site.icu-project.org/
ICU can be downloaded from GitHub. You can download the latest version of ICU from GitHub according to the system version. The latest version is 66.1, and the main updates are Unicode 13 and CLDR 36.1. The new Q1 version is used for low-risk integration of Unicode 13.

wget https://github.com/unicode-org/icu/releases/download/release-66-1/icu4c-66_1-src.tgz

Unzip the package

tar -zxf icu4c-66_1-src.tgz

Install ICU on the server and set the installation directory to /usr/local/icu

cd icu/source ./configure --prefix=/usr/local/icu make && make install

Check the newly installed version of ICU

yum info icu

I found it was 50.2. I checked on the official website and found CLDR 22.1, Unicode 6.2, ordinal support, and dictionary-based interrupt iterators for Chinese and Japanese.
At this point, the ICU library has been installed. Download and start the next step, installing the intl extension under the PHP7 installation package.
First, install the dependent software packages. If you have not configured the environment before, you need to install it again. The previously configured ones also need to be installed and tested to avoid missing them!

yum -y install make gcc-c++ gd libxml2-devel libjpeg-devel libpng-devel net-snmp-devel curl-devel libxslt-devel pcre-devel libjpeg libpng libxml2 libcurl4-openssl-dev libcurl-devel libcurl libmysqlclient freetype-config freetype freetype-devel unixODBC libxslt


After the dependency packages are installed, start installing extensions from the PHP7 installation package.
If there is no PHP7 installation package on the server, you need to download it again

wget https://www.php.net/distributions/php-7.4.3.tar.gz

Enter the extension storage directory of the PHP7 installation directory and compile and configure the intl extension.

cd php-7.4.3/ext/intl phpize ./configure make && make install


The intl extension has been installed successfully!

cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/

Use the ls command to check the directory. Intl.so has been generated. Paste the following code into the php.ini file of PHP7 and restart the PHP service.

extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/intl.so

Use VI to edit php.ini. Find a blank line and press I to start the editing mode. After pasting the above content, press ESC to cancel the editing mode. Enter the :wq command to save the file and exit VI editing.

vim /usr/local/php/etc/php.ini

Restart PHP after the system is restarted, and check whether there is an intl extension on the PHP probe page.

Congratulations, you have successfully installed the intl extension!

1/5 - (1 vote)

Leave a Reply

Your email address will not be published. Required fields are marked *