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

How to install gd library and phpize in php

WBOY
Release: 2016-07-25 08:55:20
Original
1224 people have browsed it
  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.



source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template