Dynamic compilation Add PHP module

Source: Internet
Author: User

NOTE: Reprint please indicate source: http://www.programfish.com/blog/?p=85

Many times when we build a Web server in Linux we will need to compile and install the PHP suite, and after compiling the installation, you may need to add some of the compiled installation without specifying the modules to be compiled, such as the following:
Mysql.so or mysqli.so, mbstring.so zlib.so and other modules.

Here's a hint:
If you have installed the phpMyAdmin and open the homepage after the installation is blank, it is likely that your PHP does not have MySQL and mbstring two modules.
There is also the online installation of the WordPress plugin prompted no zlib plugin is also because your PHP environment is not zlib.so this module.

The above are the author's experience, I hope to solve your problem some help.


Okay, now get to the point, and dynamically compile and add the PHP module:

Note that this post only discusses Linux environments where PHP is already installed.

If you do not want to add modules dynamically but want to reinstall the PHP environment, please visit:
Linux under the PHP environment installation:http://www.cnblogs.com/fly1988happy/archive/2011/12/14/2288096.html

At this point you need to save the PHP code that was previously compiled to install PHP. If not, you can download the same source package as the PHP version you have installed here (the version is best or close, the version may not be http://cn2.php.net/downloads.php).

And you need to know where your PHP is installed, because wait for the installation directory/bin/phpize this tool.
If you do not know where your PHP directory is installed, you can find a command to locate phpize where this file is located.

[Email protected]:~> sudo find/-name phpize
Here I found my PHP installed under/php.

OK, here i download a php-5.5.18.tar.gz this source package.
Download the good later with TAR-ZXVF decompression. (For. tar.gz compression packs only)

[Email protected]:~/temp> tar-zxvf php-5.5.18.tar.gz

Unzip to get a php-5-5-18 folder
Then the CD goes in to the EXT directory inside that directory:
[Email protected]:~/temp> cd Php-5.5.18/ext

You can see many folders after you list files with the LS command:

These are the source directories for the modules you are compiling. Here I assume the MySQL module to compile, then we will CD to the MySQL directory, if you want to compile other modules, then the CD into the corresponding module.


[Email protected]:~/temp/php-5.5.18/ext/mysql>/php/bin/phpize
When the Cd goes in, we call the Phpize script mentioned above.
   
What is a phpize script?
Mention here:
Phpize can be understood as the role of the reconnaissance environment. The Phpize tool will generate the corresponding configure file based on the configuration of the PHP you have installed.


After executing this command, you may be prompted not to install the AUTOCONF program, and if so you will have to install the software to run the command.

I don't have a problem here:

Phpize run without problems after use./configure–with-php-config=/php/bin/php-config
Here/php/bin/php-config to replace your PHP installation directory. Like/USR/LOCAL/AAA, so you're/usr/local/aaa/bin/php-config.

Execute the Make command if you do not have an error after performing this step.

If the make command is executed without an error, then the make install command is executed.

I make install here to find an error, because the normal user does not have the right to install the compiled module into the PHP installation directory.

You can execute the make install command with sudo or switch directly to the root user, and you will need to enter your password when executing.

Two things to do when make install is successful:

One is: Add a sentence to the php.ini configuration file:

Extension=mysql.so
The assumption here is to compile the MySQL module, if it is the other module name.
Like what:

If you do not know what the name of the module you just compiled, you can view it under the module directory of PHP:

I have compiled and installed 4 modules here.

NOTE: Reprint please indicate source: http://www.programfish.com/blog/?p=85

The second thing is to restart your Apache. (If you are installing Apache to provide Web services)

Dynamic compilation Add PHP module

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.