Với bài viết bạn đang chuẩn bị đọc, mình sẽ trình bày về nội dung ‘28 lỗi compile source PHP và giải pháp‘ để xử lý các lỗi này.
Việc compile (biên dịch) source PHP so với việc cài đặt bằng các repo từ ‘yum‘ thì không phải là 1 công việc dễ dàng tí nào. Lợi điểm của việc biên dịch PHP đó chính có thể tuỳ biến phiên bản PHP với các module khác nhau tuỳ nhu cầu của người cài đặt, mặt khác việc biên dịch cũng giúp PHP tương thích với hệ thống hơn.
Cái khủng khiếp khi biên dịch đó chính là việc thiếu số lượng lớn các thư viện cần thiết cho các module PHP được chỉ định sử dụng trong lúc biên dịch. Chính vì cái lẽ khổ sở thường gặp đó, nên mình sẽ liệt kê dưới đây 27 lỗi phát sinh phổ biến khi biên dịch source PHP và giải pháp xử lý bằng cách cài đặt các gói thư viện phù hợp. Hy vọng các bạn sẽ tìm thấy cách xử lý lỗi mà các bạn gặp phải ở bài viết này.
Nếu bạn lười đọc tìm từng lỗi một, compile từng lần và lòi ra từng cái lỗi lúc compile. Thì bạn có thể sử dụng lệnh cài đặt các gói thư viện được liệt kê trong bài viết này ở phía dưới, để đảm bảo các gói thư viện cơ bản đã được cài đặt, đỡ cực fix từng lỗi thiếu thư viện. Ngoài trừ các gói phải download cài đặt biên dịch nhé.
Lưu ý:
– Chỉ cài đặt các gói thư viện trên hệ thống CentOS/Fedora/RHEL do tên gói thư viện sẽ khác nếu bạn cài trên Ubuntu/Debian.
Cài đặt các thư viện đầy đủ:
# yum groupinstall "Development Tools" -y # yum install -y libcurl* libstdc++44-devel bzip2-devel bzip2 curl-devel curl libpng-devel libpng readline-devel db4-devel freetype-devel libXpm-devel gmp-devel libc-client-devel openldap-devel unixODBC-devel postgresql-devel sqlite-devel aspell-devel net-snmp-devel net-snmp libxslt-devel libxml2-devel pcre-devel t1lib-devel.x86_64 libmcrypt-devel.x86_64 libtidy libtidy-devel libjpeg-devel libjpeg8-dev mysql-devel libicu-devel recode-devel zlib zlib-devel openssl openssl-devel pcre pcre-devel enchant enchant-devel
Contents
- Top 28 lỗi compile source PHP và giải pháp
- 1. Lỗi bzip
- 2. Lỗi ‘cURL’
- 3. Lỗi ‘png.h’
- 4. Lỗi ‘db4’
- 5. Lỗi ‘xpm’
- 6. Lỗi ‘libXpm’
- 7. Lỗi ‘gmp’
- 8. Lỗi ‘libc’
- 9. Lỗi ‘ldap’
- 10. Lỗi ‘unixODBC’
- 11. Lỗi ‘postgresql’
- 12. Lỗi ‘sqlite’
- 13. Lỗi ‘aspell’
- 14. Lỗi ‘net-snmp’
- 15. Lỗi ‘libxslt-devel’
- 16. Lỗi ‘libxml’
- 17. Lỗi ‘pcre-devel’
- 18. Lỗi ‘libidn’
- 19. Lỗi ‘libxml2.la’
- 20. Lỗi ‘t1lib’
- 21. Lỗi ‘mcrypt.h:
- 22. Lỗi ‘libtidy’
- 23. Lỗi ‘jpeglib.h’
- 24. Lỗi ‘mysql-devel’
- 25. Lỗi ‘libicu’
- 26. Lỗi ‘recode.h’
- 27. Lỗi ‘mm’
- 28. Lỗi ‘enchant library’
Top 28 lỗi compile source PHP và giải pháp
1. Lỗi bzip
checking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distribution
Giải pháp:
# yum install bzip2-devel bzip2
2. Lỗi ‘cURL’
checking for cURL support… yes checking if we should use cURL for url streams… no checking for cURL in default path… not found configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/
Giải pháp:
# yum install curl-devel curl
3. Lỗi ‘png.h’
checking for fabsf… yes checking for floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error: png.h not found.
Giải pháp:
# yum install libpng-devel libpng
4. Lỗi ‘db4’
checking for curl_multi_strerror in -lcurl… yes checking for QDBM support… no checking for GDBM support… no checking for NDBM support… no configure: error: DBA: Could not find necessary header file(s).
Giải pháp:
# yum install db4-devel
5. Lỗi ‘xpm’
checking for png_write_image in -lpng… yes If configure fails try –with-xpm-dir= configure: error: freetype.h not found.
Giải pháp:
– Configure lại lúc biên dịch PHP với option sau : –with-xpm-dir=/usr
– Cài thêm thư viện ‘freetype’
# yum install freetype-devel
6. Lỗi ‘libXpm’
checking for png_write_image in -lpng… yes configure: error: libXpm.(a|so) not found.
Giải pháp:
# yum install libXpm-devel
7. Lỗi ‘gmp’
checking for bind_textdomain_codeset in -lc… yes checking for GNU MP support… yes configure: error: Unable to locate gmp.h
Giải pháp:
# yum install gmp-devel
8. Lỗi ‘libc’
checking for utf8_mime2text signature… new checking for U8T_DECOMPOSE… configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
Giải pháp:
# yum install libc-client-devel
9. Lỗi ‘ldap’
checking for LDAP support… yes, shared checking for LDAP Cyrus SASL support… yes configure: error: Cannot find ldap.h
Giải pháp:
# yum install openldap-devel
10. Lỗi ‘unixODBC’
checking for mysql_set_character_set in -lmysqlclient… yes checking for mysql_stmt_next_result in -lmysqlclient… no checking for Oracle Database OCI8 support… no checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
Giải pháp:
# yum install unixODBC-devel
11. Lỗi ‘postgresql’
checking for PostgreSQL support for PDO… yes, shared checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
Giải pháp:
# yum install postgresql-devel
12. Lỗi ‘sqlite’
checking for sqlite 3 support for PDO… yes, shared checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path… not found configure: error: Please reinstall the sqlite3 distribution
Giải pháp:
# yum install sqlite-devel
13. Lỗi ‘aspell’
checking for utsname.domainname… yes checking for PSPELL support… yes configure: error: Cannot find pspell
Giải pháp:
# yum install aspell-devel
14. Lỗi ‘net-snmp’
checking whether to enable UCD SNMP hack… yes checking for default_store.h… no checking for kstat_read in -lkstat… no checking for snmp_parse_oid in -lsnmp… no checking for init_snmp in -lsnmp… no configure: error: SNMP sanity check failed. Please check config.log for more information.
Giải pháp:
# yum install net-snmp-devel net-snmp
15. Lỗi ‘libxslt-devel’
checking whether to enable XMLWriter support… yes, shared checking for xml2-config path… (cached) /usr/bin/xml2-config checking whether libxml build works… (cached) yes checking for XSL support… yes, shared configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
Giải pháp:
# yum install libxslt-devel
16. Lỗi ‘libxml’
configure: error: xml2-config not found. Please check your libxml2 installation.
Giải pháp:
# yum install libxml2-devel
17. Lỗi ‘pcre-devel’
checking for PCRE headers location… configure: error: Could not find pcre.h in /usr
Giải pháp:
# yum install pcre-devel
18. Lỗi ‘libidn’
libtool: link: cannot find the library `/usr/lib/libidn.la’ or unhandled argument `/usr/lib/libidn.la’ make: *** [sapi/cgi/php-cgi] Error 1
Giải pháp:
– Tải gói thư viện ‘libidn’ này về và cài đặt.
# cd /usr/src/ # wget http://ftp.gnu.org/gnu/libidn/libidn-1.33.tar.gz # tar -zvxf libidn-1.33.tar.gz # cd libidn-1.33 # ./configure # make # make install # ln -s /usr/local/lib/libidn.la /usr/lib/libidn.la
19. Lỗi ‘libxml2.la’
libtool: link: `/usr/lib/libxml2.la’ is not a valid libtool archive make: *** [ext/xsl/xsl.la] Error 1
Giải pháp:
– Cài đặt libxml thư viện riêng.
# cd /usr/src/ # wget ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz # tar -zvxf libxml2-2.9.4.tar.gz # cd libxml2-2.9.4 # ./configure –prefix=/usr # make # make install
20. Lỗi ‘t1lib’
configure: error: Your t1lib distribution is not installed correctly. Please reinstall it.
Giải pháp:
# yum install t1lib-devel.x86_64
21. Lỗi ‘mcrypt.h:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
Giải pháp:
# yum install libmcrypt-devel.x86_64
22. Lỗi ‘libtidy’
configure: error: Cannot find libtidy
Giải pháp:
# yum install libtidy libtidy-devel
23. Lỗi ‘jpeglib.h’
checking for fabsf… yes checking for floorf… yes configure: error: jpeglib.h not found.
Giải pháp:
# yum install libjpeg-devel libjpeg8-dev
24. Lỗi ‘mysql-devel’
configure: error: Cannot find MySQL header files under /usr. Note that the MySQL client library is not bundled anymore!
Giải pháp:
– Lưu ý là các bạn nên cài đặt dịch vụ MySQL trước, để lúc cài đặt MySQL sẽ được cài đặt kèm thư viện MySQL nhằm hỗ trợ PHP kết nối đến dịch vụ MySQL phù hợp phiên bản thư viện tương ứng MySQL đang chạy.
– Nếu bạn cài dịch vụ ‘MySQL‘ bằng yum thì có thể cài thêm thư viện ‘mysql-devel‘ bằng yum luôn, còn nếu cài bằng các gói ‘.rpm‘ thì nên download bản cài ‘dev’ .rmp tương ứng version MySQL rồi cài.
# yum install mysql-devel
25. Lỗi ‘libicu’
configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
Giải pháp:
# yum install libicu-devel
26. Lỗi ‘recode.h’
configure: error: Can not find recode.h
Giải pháp:
# yum install recode-devel
27. Lỗi ‘mm’
error: cannot find mm library
Giải pháp:
# wget http://pkgs.fedoraproject.org/repo/pkgs/mm/mm-1.4.2.tar.gz/bdb34c6c14071364c8f69062d2e8c82b/mm-1.4.2.tar.gz # tar -zxvf mm-1.4.2.tar.gz # ./configure # make # make install
28. Lỗi ‘enchant library’
checking for ENCHANT support... yes, shared configure: error: Cannot find enchant
Giải pháp:
# yum install enchant enchant-devel -y
Vậy thôi, cực kì đơn giản để cài đặt các gói thư viện tương ứng trên hệ thống CentOS hỗ trợ việc cài đặt compile PHP.