Install intl PHP 7.1 extension in a PHP multiple version server

Discussion in 'Installation/Configuration' started by Enrique García, Jan 29, 2017.

  1. Kojo Unsui likes this.
  2. florian030

    florian030 Well-Known Member HowtoForge Supporter

    I did not tried it, but it should work

    Code:
    cd /opt/php-7.1/etc
    pecl update-channels
    pecl install intl
    echo extension=intl.so >> /opt/php-7.1/lib/php.ini
     
  3. Hbod

    Hbod Member

    This won't work for many reasons. pecl install intl would install that for the default PHP Version, not the one inside /opt/. The right way would be to

    > pecl -C ./pear.conf install intl

    But also this won't work, as the compiling intl-source is updated 3 years ago and will complain and terminate compiling
    /tmp/pear/temp/intl/intl_error.h:24:40: fatal error: ext/standard/php_smart_str.h: No such file or directory
    #include <ext/standard/php_smart_str.h>

    as php_start_str was renamed to php_start_string in PHP7. I don't see any way to get this installed. So bad! Any ideas?
     
  4. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Actually there is another option to install multiple php version and use them together via ISPC with your preferred extensions for them, that is via installing ondrej ppa like this:
    Code:
    add-apt-repository ppa:ondrej/php
    apt-get update && apt-get -y upgrade
    Afterwards you install php version that you want i.e. php5.6 to php7.1 as prescribed in the How Tos (Note that php5.5 is no longer supported) something like this:
    Code:
    apt-get -y install php7.1-opcache php7.1-fpm php7.1 php7.1-common php7.1-gd php7.1-mysql php7.1-imap php7.1-cli php7.1-cgi php-pear php-auth php7.1-mcrypt mcrypt imagemagick libruby php7.1-curl php7.1-intl php7.1-pspell php7.1-recode php7.1-sqlite3 php7.1-tidy php7.1-xmlrpc php7.1-xsl memcached php-memcache php-imagick php-gettext php7.1-zip php7.1-mbstring
    Then in your ISPC Additional PHP Settings > For FastCGI add something like:
    Code:
    Path to the PHP FastCGI binary = /usr/bin/php-cgi7.1
    Path to the php.ini directory = /etc/php/7.1/cgi
    
    For > PHP-FPM
    Code:
    Path to the PHP-FPM init script = /etc/init.d/php7.1-fpm
    Path to the php.ini directory = /etc/php/7.1/fpm
    Path to the PHP-FPM pool directory = /etc/php/7.1/fpm/pool.d
    
    For some it is easier to add phpVersions and their extensions this way, but for others adding them without relying to ondrej ppa is preferred.

    If your server is still on testing and not on production yet, you may want to give this another-way-around a try. ;)
     
    Last edited: Mar 1, 2017
    etruel, Taleman and gOOvER like this.
  5. Rafael Santana

    Rafael Santana New Member



    ahrasis, Just follow these steps quoted above by you is will work?
     
    Last edited: Jun 11, 2017
  6. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Yes. This is the simplest way I know that work with my Ubuntu 16.04 built. Most of my sites use php7.1 that is installed using this trick.

    Please note my server is a private server i.e. for private use only. So those who intend to run a public server should follow the guide / tutorial instead of the mentioned trick.
     
  7. Rafael Santana

    Rafael Santana New Member

    I also tried to follow the steps for installing PHP 7.1 on Debian 8 from this link.
    https://www.howtoforge.com/tutorial/how-to-install-php-7-on-debian/



    But he made some mistakes in "Copy php.ini and php-fpm.conf to the correct locations - step":

    Copy php.ini and php-fpm.conf to the correct locations:

    cp /usr/local/src/php7-build/php-7.1.2/php.ini-production /opt/php-7.1/lib/php.ini
    cp /opt/php-7.1/etc/php-fpm.conf.default /opt/php-7.1/etc/php-fpm.conf
    cp /opt/php-7.1/etc/php-fpm.d/www.conf.default /opt/php-7.1/etc/php-fpm.d/www.conf



    Always the error message below appears:
    root@server:/usr/local/src/php7-build/php-7.1.2# cp /usr/local/src/php7-build/php-7.1.2/php.ini-production /opt/php-7.1/lib/php.ini
    cp: cannot create regular file '/opt/php-7.1/lib/php.ini': No such file or directory
    root@server:/usr/local/src/php7-build/php-7.1.2# cp /opt/php-7.1/etc/php-fpm.conf.default /opt/php-7.1/etc/php-fpm.conf
    cp: cannot stat '/opt/php-7.1/etc/php-fpm.conf.default': No such file or directory
    root@server:/usr/local/src/php7-build/php-7.1.2# cp /opt/php-7.1/etc/php-fpm.d/www.conf.default /opt/php-7.1/etc/php-fpm.d/www.conf
    cp: cannot stat '/opt/php-7.1/etc/php-fpm.d/www.conf.default': No such file or directory

    I would like to add PHP 7.1 as an additional version. I can not go on from this point forward.
    Has anyone been able to perform this setup?
     
  8. Rafael Santana

    Rafael Santana New Member

  9. florian030

    florian030 Well-Known Member HowtoForge Supporter

    you missed at least one step:
    mkdir /opt/php-7.1
     
  10. Rafael Santana

    Rafael Santana New Member

    root@server:~# mkdir /opt/php-7.1
    mkdir: cannot create directory '/opt/php-7.1': File exists
     
  11. dimiandre

    dimiandre New Member

    Hi guys!
    i've found a solution for this without having to use the ondrej ppa that's not safe for production environments.
    From php 5.5 php-intl it's alredy included in PHP binary, it just have to be enabled during the configuration of the build.

    If you are reading this you probably compiled PHP 7 by yourself to have two-three version on the same machine, in my case i'm using debian and nginx

    First, locate your old build folder. I Hope you didn't deleted that, in my case was:
    Code:
    cd /usr/local/src/php7-build
    cd php-7.1.2
    
    now you have to re-configure the build including the "--enable-intl" option.
    Code:
    ./configure --prefix=/opt/php-7.1 --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-mcrypt --with-zlib --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm --enable-intl
    now just make && make install
    restart php-fpm and you are done.

    /etc/init.d/php-7.1-fpm stop
    /etc/init.d/php-7.1-fpm start
     
    Ludowan, etruel, Ark74 and 2 others like this.
  12. lollollollol

    lollollollol Member

    Well done @dimiandre, thank you.
    And you are right about ppa, the worst thing to do ...

    By the way compiling php 7.2.0 give me two errors:
    Code:
    configure: WARNING: unrecognized options: --with-mcrypt, --enable-gd-native-ttf
    mcrypt and gd-native-ttf options should probably be removed. I have not found (or really looked for ...) a workaround.
     
  13. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    There is no mcrypt in php7.2 but I am not sure about gd-native-ttf.
     
  14. wojtekgoral

    wojtekgoral New Member

    When I enter this command :
    Code:
    ./configure --prefix=/opt/php-7.2 --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-zlib --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-jpeg-dir=/usr --with-png-dir=/usr --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm --enable-intl
    
    I get:
    Code:
    ...
    checking for icu-config... no
    checking for location of ICU headers and libraries... not found
    configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
    
    So I installed ICU using these commands:
    Code:
    wget http://download.icu-project.org/files/icu4c/59.1/icu4c-59_1-src.tgz
    tar zxf icu4c-59_1-src.tgz
    cd icu/source
    ./configure --prefix=/opt/icu && make && make install
    
    I also tried to add --with-icu-dir=/opt/icu
    but then there are other errors as below
    Code:
    Generating files
    configure: creating ./config.status
    creating main/internal_functions.c
    gawk: ./build/print_include.awk:1: fatal: cannot open file `ext/standard/php_smart_str.h' for reading (No such file or directory)
    creating main/internal_functions_cli.c
    gawk: ./build/print_include.awk:1: fatal: cannot open file `ext/standard/php_smart_str.h' for reading (No such file or directory)
    
    Then I checked
    /usr/local/src/php7.2build/php-7.2.2/ext/standard directory for the file and there is php_smart_string.h file. So I copied it into php_smart_str.h file and now the config goes smooth and the line above now shows
    Code:
    Generating files
    configure: creating ./config.status
    creating main/internal_functions.c
    creating main/internal_functions_cli.c
    
    then make showed errors in 'red', so I used
    Code:
    make clean
    then
    Code:
    make
    I see errors similar to this one

    Code:
    warning: ‘TLSv1_2_server_method’ is deprecated [-Wdeprecated-declarations]
    
    but it does not finish due to these errors

    Code:
    In file included from /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:21:0:
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.h:29:25: error: ‘UnicodeString’ was not declared in this scope
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status);
                             ^~~~~~~~~~~~~
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.h:29:25: note: suggested alternative:
    In file included from /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.h:26:0,
                     from /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:21:
    /opt/icu/include/unicode/unistr.h:289:20: note:   ‘icu_64::UnicodeString’
     class U_COMMON_API UnicodeString : public Replaceable
                        ^~~~~~~~~~~~~
    In file included from /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:21:0:
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.h:29:40: error: ‘ret’ was not declared in this scope
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status);
                                            ^~~
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.h:29:45: error: expected primary-expression before ‘char’
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status);
                                                 ^~~~
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.h:29:63: error: expected primary-expression before ‘str_len’
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status);
                                                                   ^~~~~~~
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.h:29:83: error: expected primary-expression before ‘*’ token
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status);
                                                                                       ^
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.h:29:84: error: ‘status’ was not declared in this scope
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status);
                                                                                        ^~~~~~
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.h:29:90: error: expression list treated as compound expression in initializer [-fpermissive]
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status);
                                                                                              ^
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.h:31:40: error: ‘UnicodeString’ does not name a type
     zend_string* intl_charFromString(const UnicodeString &from, UErrorCode *status);
                                            ^~~~~~~~~~~~~
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:28:25: error: redefinition of ‘int intl_stringFromChar’
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status)
                             ^~~~~~~~~~~~~
    In file included from /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:21:0:
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.h:29:5: note: ‘int intl_stringFromChar’ previously defined here
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status);
         ^~~~~~~~~~~~~~~~~~~
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:28:25: error: ‘UnicodeString’ was not declared in this scope
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status)
                             ^~~~~~~~~~~~~
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:28:25: note: suggested alternative:
    In file included from /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.h:26:0,
                     from /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:21:
    /opt/icu/include/unicode/unistr.h:289:20: note:   ‘icu_64::UnicodeString’
     class U_COMMON_API UnicodeString : public Replaceable
                        ^~~~~~~~~~~~~
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:28:40: error: ‘ret’ was not declared in this scope
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status)
                                            ^~~
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:28:45: error: expected primary-expression before ‘char’
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status)
                                                 ^~~~
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:28:63: error: expected primary-expression before ‘str_len’
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status)
                                                                   ^~~~~~~
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:28:83: error: expected primary-expression before ‘*’ token
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status)
                                                                                       ^
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/intl_convertcpp.cpp:28:84: error: ‘status’ was not declared in this scope
     int intl_stringFromChar(UnicodeString &ret, char *str, size_t str_len, UErrorCode *status)
                                                                                        ^~~~~~
    Makefile:1110: recipe for target 'ext/intl/intl_convertcpp.lo' failed
    make: *** [ext/intl/intl_convertcpp.lo] Error 1
    
    
    Please help.
     
    Last edited: May 1, 2019
  15. wojtekgoral

    wojtekgoral New Member

    Later I tried with ICU 64rc2 but I get
    Code:
    ...................
    
    ext/intl/uchar/.libs/uchar.o: In function `convert_cp':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/uchar/uchar.c:24: undefined reference to `utf8_nextCharSafeBody_59'
    ext/intl/uchar/.libs/uchar.o: In function `zim_IntlChar_getFC_NFKC_Closure':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/uchar/uchar.c:561: undefined reference to `u_getFC_NFKC_Closure_59'
    ext/intl/uchar/.libs/uchar.o: In function `zim_IntlChar_charName':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/uchar/uchar.c:256: undefined reference to `u_charName_59'
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/uchar/uchar.c:259: undefined reference to `u_charName_59'
    ext/intl/uchar/.libs/uchar.o: In function `convert_cp':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/uchar/uchar.c:24: undefined reference to `utf8_nextCharSafeBody_59'
    ext/intl/idn/.libs/idn.o: In function `php_intl_idn_to':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/idn/idn.c:227: undefined reference to `uidna_IDNToASCII_59'
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/idn/idn.c:229: undefined reference to `uidna_IDNToUnicode_59'
    ext/intl/idn/.libs/idn.o: In function `php_intl_idn_to_46':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/idn/idn.c:147: undefined reference to `uidna_openUTS46_59'
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/idn/idn.c:157: undefined reference to `uidna_nameToUnicodeUTF8_59'
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/idn/idn.c:161: undefined reference to `uidna_close_59'
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/idn/idn.c:154: undefined reference to `uidna_nameToASCII_UTF8_59'
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/idn/idn.c:195: undefined reference to `uidna_close_59'
    ext/intl/spoofchecker/.libs/spoofchecker_class.o: In function `spoofchecker_object_destroy':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/spoofchecker/spoofchecker_class.c:178: undefined reference to `uspoof_close_59'
    ext/intl/spoofchecker/.libs/spoofchecker_class.o: In function `spoofchecker_clone_obj':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/spoofchecker/spoofchecker_class.c:116: undefined reference to `uspoof_clone_59'
    ext/intl/spoofchecker/.libs/spoofchecker_create.o: In function `zim_Spoofchecker___construct':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/spoofchecker/spoofchecker_create.c:43: undefined reference to `uspoof_open_59'
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/spoofchecker/spoofchecker_create.c:54: undefined reference to `uspoof_setRestrictionLevel_59'
    ext/intl/spoofchecker/.libs/spoofchecker_main.o: In function `zim_Spoofchecker_isSuspicious':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/spoofchecker/spoofchecker_main.c:41: undefined reference to `uspoof_checkUTF8_59'
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/spoofchecker/spoofchecker_main.c:44: undefined reference to `u_errorName_59'
    ext/intl/spoofchecker/.libs/spoofchecker_main.o: In function `zim_Spoofchecker_areConfusable':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/spoofchecker/spoofchecker_main.c:79: undefined reference to `u_errorName_59'
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/spoofchecker/spoofchecker_main.c:76: undefined reference to `uspoof_areConfusableUTF8_59'
    ext/intl/spoofchecker/.libs/spoofchecker_main.o: In function `zim_Spoofchecker_setAllowedLocales':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/spoofchecker/spoofchecker_main.c:106: undefined reference to `uspoof_setAllowedLocales_59'
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/spoofchecker/spoofchecker_main.c:109: undefined reference to `u_errorName_59'
    ext/intl/spoofchecker/.libs/spoofchecker_main.o: In function `zim_Spoofchecker_setChecks':
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/spoofchecker/spoofchecker_main.c:129: undefined reference to `uspoof_setChecks_59'
    /usr/local/src/php7.2-build/php-7.2.2/ext/intl/spoofchecker/spoofchecker_main.c:132: undefined reference to `u_errorName_59'
    collect2: error: ld returned 1 exit status
    Makefile:297: recipe for target 'sapi/cli/php' failed
    make: *** [sapi/cli/php] Error 1
    
    
     
  16. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Compiling is good but using this method, it will very hard to keep track with the latest updates. My preferred way is in reply #4.
     
  17. wojtekgoral

    wojtekgoral New Member

    Hello.
    ahrasis thank You for the reply. I want to have multiple php versions on the server and perhaps compiling is the only way, because apt-get will overwrite the previous version. Also I read that ondrej/php is not good for production server. If You know how to avoid problems during compilation or how to compile in other way incl. intl module - please kindly let me know.
     
  18. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    The way I mentioned is for multiple php and it does not overwrite any other version you did not install.

    However, it will change default php to the latest one install.

    For example, if you installed php7.3 on Ubuntu 18.04 which its default is php7.2, the default will be changed to php7.3.

    You can always easily revert it back to php7.2 without uninstalling php7.3.

    I think there is an official tutorial for Debian regarding this Ondrej Sury multiple php installation too.

    So far that I know it is very much safe and has been in use for production by many servers.

    That all being said, it matter of choice and it is up to you to decide which one you think is best for your server, in production or otherwise.

    Good luck.
     

Share This Page