Home Backend Development PHP Tutorial How to install gd library and phpize in php

How to install gd library and phpize in php

Jul 25, 2016 am 08:55 AM

  1. [root@jbxue achievo]# php -v
  2. PHP 5.3.6 (cli) (built: Aug 19 2011 19:35:20)
  3. Copyright (c) 1997-2011 The PHP Group
  4. Zend Engine v2 .3.0, Copyright (c) 1998-2011 Zend Technologies
Copy code

二,phpize 1. What is phpize phpize is used to extend php extension modules, and php plug-in modules can be created through phpize.

When installing php, you need to use phpize:

  1. './configure' '--prefix=/usr/local/php' '--with-mysql=/usr/local/mysql' '--with-zlib-dir' '--with -freetype-dir=/usr' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--with-gd' '--enable-ftp' '--with-iconv' '--with-gettext' '--with-curl' '--enable-fastcgi' '--with-openssl'
Copy code

The following parameters are the required modules. Sometimes you need to add some modules without recompiling PHP. In this case, you can use phpize to help plug-in modules.

2. How to use phpize? When php is compiled, there will be a phpize script file in the bin directory of php. Before compiling the extension module to be added, just execute the following phpize;

  1. # If you forget to add some modules during compilation, you can use this method to recompile and add them!
  2. # First, enter the extension directory of the PHP directory (not compiled)
  3. cd /home/soft/php-5.2.14/ext/ftp/
  4. # Call the phpize program to generate the compilation configuration file
  5. # find / -name phpize
  6. /usr /local/php/bin/phpize
  7. Configuring for:
  8. PHP Api Version: 20041225
  9. Zend Module Api No: 20060613
  10. Zend Extension Api No: 220060519
  11. # Compile extension library
  12. /configure –with-php-config=/usr/ local/php/bin/php-config
  13. make
  14. # After make is successfully executed, the generated extension library file will be in the modules subdirectory of the current directory
  15. # Edit the php.ini document, find the directory of extension_dir, and compile the extension file Copy to extension
  16. vim /usr/local/php/etc/php.ini
  17. # Line 491
  18. # extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613 /”
  19. cp ftp.so /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
  20. # In the add extension library location of php.ini, set the extension library to be added.
  21. # Add extension=ftp.so at 612
  22. # Restart webservice
Copy code

-------------------------- ---------------------------- The php source code location of 181 is at /root/software/php-5.3.6

Try to install a Xenforo forum on the above platform. When the installation starts, the following message is prompted: The following errors occurred while verifying that your server can run XenForo: * The required PHP extension MySQLi could not be found. Please ask your host to install this extension. * The required PHP extension GD could not be found. Please ask your host to install this extension.

Since PHP is compiled and installed from source code, the above two extensions are not installed. The following is the process of adding these two extensions to PHP:

1. Install GD extension 1. Download and install the source code package required for the GD library extension (you can click the source code package to download directly) gd-2.0.35.tar.gz http://www.libgd.org/releases/ jpegsrc.v8b.tar.gz http://www.ijg.org/ libpng-1.5.0.tar.gz http://sourceforge.net/projects/libpng/ freetype-2.4.4.tar.gz http://sourceforge.net/projects/freetype/ zlib-1.2.3.tar.gz

2. Compile and install each source code package separately 1), install zlib

  1. tar zxvf zlib-1.2.3.tar.gz
  2. cd zlib-1.2.3
  3. ./configure
  4. make
  5. make install
Copy the code

2), install libpng

  1. tar zxvf libpng-1.5.0.tar.tar
  2. cd libpng-1.5.0
  3. cd scripts
  4. mv makefile.linux ../makefile
  5. cd ..
  6. make
  7. make install
Copy code

3), install freetype

  1. tar zxvf freetype-2.4.4.tar.gz
  2. cd freetype-2.4.4
  3. ./configure
  4. make
  5. make install
Copy code

4), install Jpeg

  1. tar zxvf jpegsrc.v8b.tar.gz
  2. cd jpeg-8b
  3. ./configure –enable-shared
  4. make
  5. make test
  6. make install
Copy code
Note , configure must be here You must bring the –enable-shared parameter, otherwise the shared library will not be generated.

5), install GD library

  1. tar zxvf gd-2.0.33.tar.gz
  2. cd gd-2.0.33
  3. ./configure –with-png –with-freetype –with-jpeg
  4. make install
Copy code

3. Recompile and install PHP (that is, add the parameters related to the above installation after the parameters of the previous compilation of PHP) cd php-5.3.4 (enter the previous PHP source code directory)

  1. ./configure –prefix=/opt/php –with-mysql=/opt/mysql –with-apxs2=/opt/apache/bin/apxs –enable-track-vars –enable-force-cgi -redirect –with-config-file-path=/opt/php/etc –with-gd –enable-gd-native-ttf –with-zlib –with-png –with-jpeg –with-freetype –enable-sockets
Copy code

The green font part is the parameters added when installing PHP before:

  1. make
  2. make install
Copy the code

In this way, the GD library extension is installed. Restart Apache and check the PHP information test page to see the gd item;

2. Install MySQLi extension phpize is used here. The phpize command is used to prepare the PHP extension library compilation environment. Generally, after installing PHP, you will find this command in the bin directory where PHP is installed. If a prompt such as autoconf cannot be found appears after executing the phpize command, please install autoconf and execute it again. Netizens are asked to modify the directory path of the following instructions according to the actual situation of their own system. The EXT folder under the PHP source code package folder contains the available extensions of the current version. CD into it to see what you need? You should see the mysqli folder.

  1. cd /opt/software/php-5.3.4/ext/mysqli
Copy the code

Execute phpize in the current directory

  1. [root@jbxue mysqli]#/opt/php/bin/phpize
  2. Configuring for:
  3. PHP Api Version: 20090626
  4. Zend Modeule Api No: 20090626
  5. Zend Extension Api No: 22009062 6
  6. [root@jbxue mysqli]#./configure –prefix=/opt/mysqli –with-php-config=/opt/php/bin/php-config –with-mysqli=/opt/mysql/bin/mysql_config
  7. [root@jbxue mysqli] #make
  8. [root@jbxue mysqli]#make install
Copy the code

After the installation is complete, you will be prompted for the directory path where the extension is located, for example: /opt/php/lib/php/extensions/no-debug-zts-20090626 The required mysqli.so will be in this directory.

Next, modify the php.ini file under /opt/php/etc/ and add the mysqli extension:

  1. extension=/opt/php/lib/php/extensions/no-debug-zts-20090626/mysqli.so
Copy the code

Restart the Apache service and open the PHP information page again. See the MySQLi entry.



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

Customizing/Extending Frameworks: How to add custom functionality. Customizing/Extending Frameworks: How to add custom functionality. Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

What exactly is the non-blocking feature of ReactPHP? How to handle its blocking I/O operations? What exactly is the non-blocking feature of ReactPHP? How to handle its blocking I/O operations? Apr 01, 2025 pm 03:09 PM

An official introduction to the non-blocking feature of ReactPHP in-depth interpretation of ReactPHP's non-blocking feature has aroused many developers' questions: "ReactPHPisnon-blockingbydefault...

See all articles