Install and compile the php Extension Module

Source: Internet
Author: User
Install and compile the php Extension Module

Php extension module installation and writing. if you need it, you can refer to it.


1. install PHP source code (using php6 as an example)

Download the php6 source code from the official website and decompress it.

Enter the decompressed folder

./Buildconf -- force

./Configure -- prefix =/usr/local/php6 -- enable-fpm

The preceding two rows are used to configure the installation information./indicates that the program in the current directory is used, and -- prefix indicates the directory to be installed.

Make compile php source code

Make install installation

/Usr/local/php6/bin-v can be used to test whether the installation is successful.


2. PHP extension module installation

How to load a module (pcntl)

Run the cd command to go to the ext/pcntl folder under the source code.

/Usr/local/php6/bin/phpizephpize program is used to load an extension program. here you need to use the phpize of the php to load the extension (if you have multiple php files)

. /Configure -- with-php-config =/usr/local/php6/bin/php-config: configure the extension module information, the reason for the following path is the same as above (select the php configuration that needs to be loaded with expansion). This is to make the configuration of php and the extension module the same

Make compilation

After compilation, pcntl. so is generated under modules in the current directory.

Copy pcntl. so to the php installation directory (preferably under ext)

Modify php. ini (you can search for php by running phpinfo. ini method to find this file, usually under lib, if the path found does not have php. ini needs to create one by yourself)

Add the extensions = pcntl. so path to the file.

Then you can run it.


3. PHP custom extension module

Assume that a function called computeDistance (positionX, positionY) is required.

Compile the distance. skel file

Int computeDistance (int positionX, int positionY) indicates what modules we need.

./Ext_skel -- extname = distance -- proto = distance. skel

The above code uses the ext_skel program to generate two parameters of the entire module: The module name and the module description file.

Enter the generated module folder

Modify config. m4

Dnl PHP_ARG_WITH (ccvita, for ccvita support,

DnlMake sure that the comment is aligned:

Dnl [-- with-distance Include distance support])

Delete dnl before the three rows

Modify distance. c

Find the PHP_FUNCTION and change the parameter to computeDistance, that is, change the name of the function to be called and modify the function content.

The subsequent steps are the same as those above.

Phpize

./Configure

Make

Copy

Modify configuration file


Php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.