Linux PHP compiler add the corresponding dynamic expansion module so (do not need to recompile PHP, take openssl.so as an example)

Source: Internet
Author: User
Tags php compiler php source code

This article turns from: Original link http://www.cnblogs.com/doseoer/p/4367536.html

I see there are a lot of related articles on the Internet, but after all, because of many Linux versions, many liunx commands or paths are different, sometimes the same command can not perform the same operation.

This article is my practical use in the configuration of successful instances, I hope to help you, open source is from everyone's selfless help, everyone's growth is to need someone's support! That's what the crap says!

http://php.net/downloads.php (Download the corresponding PHP version)

1. First determine the installed PHP version of Linux, because different PHP version for the addition of dynamic modules have compatibility issues (possible path, configuration?). Other? ), often error can not be installed, the additional module must be the same version.

There are several ways to view the PHP version:

① run php-v (but in my 64-bit LIUNX test did not work, reason you know!) )

② found in the installed PHP path php-config and view, can VI or CAT (keyword: Version = "XXXXXXX"for the PHP version number)

VI or Cat Php-config

2, download the PHP source code package to manually upload to the FTP network server, then your tar package may just put on the WWW, for your own convenience to find and use, it is recommended to establish their own source folder for storage.

Create folder: mkdir XXXXXX (folder name)

Move or copy files: MV or CP php.tar/sourece (note the path, "/" I am the temporary folder created under the root directory!) )

Unzip the TAR package: Tar zxfv php.tar (source code tar package)

3, now into the topic, to add Dynamic module openssl.so as an example, into the PHP source folder, the execution of phpize generation Configure module Append:

#cd/source/php/ext/openssl the OpenSSL module folder into the source package

#/var/www/php/bin/phpize Note that this is an installed PHP path (some versions may be under/usr/local/******, everyone's installation habits are different)

If the following error occurs: Cannot find CONFIG.M4. *****************************************

Workaround:

Check the source package OpenSSL folder for CONFIG0.M4, if there is an executable,
#mv CONFIG0.M4 CONFIG.M4

4, into the final compilation stage, I compile is relatively smooth (sometimes error if appear, I also do not elaborate, can only rely on their own view errorlog log)

#./configure--with-openssl--with-php-config=/var/www/php/bin/php-config (Note: After this parameter is your native installed PHP path)
#make

#make Test (Compile results)

#make Install

Success information is returned when successful (note where the so file is located):

Installing Shared extensions:/usr/lib/20060613/(this path is my virtual, please find yourself, will generate openssl.so files)

General specification point, the additional so module will be placed in a specified folder, in PHP installed directory under the Extensions folder

#mv/*****/*****/openssl.so/var/www/php/lib/php/extensions

Dynamic module Append compilation has been completed ....

Finally, PHP support to load these additional dynamic modules, vi editor PHP under the configuration file php.ini.

#vi/*******/*******/php.ini

After entering the editor, you can see all the relevant configuration of PHP and find the option of Extension_dir this configuration.

VI can be directly after the '/extension_dir ' search, found after this may be:

Extension_dir = "./"

To be modified to:

Extension_dir = "/var/www/php/lib/php/extensions/" (note where the so file is located)

extension=openssl.so (so module file name)
Last Save exit! : wq!

Then you restart the Apache server! (there is said that people do not, but also a command, I think the configuration is good to restart or peace of mind!) )

You can use the command to view the next PHP run load:/var/www/php/bin/php-m|grep OpenSSL (path What I will not say, is the installation of the PHP path just)

There may be some errors in the message, but it's all right: like no DLL file found AH (Openssl.dll), leave him, DLL is the type of Windows Host Server module loading, UNIX and Linux are loaded with so module name!

Linux PHP compiler add the corresponding dynamic expansion module so (do not need to recompile PHP, take openssl.so as an example)

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.