Home  >  Article  >  Backend Development  >  Dynamically compile and add php module, compile php module_PHP tutorial

Dynamically compile and add php module, compile php module_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:14:08877browse

Dynamic compilation adds php module, compiles php module

Dynamically compile and add php module, compile php module_PHP tutorial

Note: Please indicate the source for reprinting: http://www.programfish.com/blog/?p=85

Many times when we build a web server in Linux, we need to compile and install the PHP package. After compilation and installation, we may need to add some modules that were not specified to be compiled during compilation and installation, such as the following situation:
Mysql.so or mysqli.so, mbstring.so zlib.so and other modules.

Here’s a reminder:
If you have installed phpmyadmin and the homepage is blank after installation and configuration, then it is very likely that your php does not have the mysql and mbstring modules.
Also, when installing the wordpress plug-in online, it prompts that there is no zlib plug-in because there is no zlib.so module in your php environment.

The above is what the author has experienced, and I hope it can be helpful to solve your problem.


Okay, now let’s get to the point, dynamically compile and add the php module:

Please note that this blog post only discusses the Linux environment where PHP has been installed.

If you don’t want to add modules dynamically but want to reinstall the php environment, please go to:
Php environment installation under Linux: http://www.cnblogs.com/fly1988happy/archive/2011/12/14/2288096.html

At this time you need to save the php source code used when compiling and installing php. If not, you can go to http://cn2.php.net/downloads.php to download the source code package that is the same as the PHP version you have installed (the version here should be the same or close to it. Different versions may cause discomfort. match).

You also need to know where your php is installed, because you will need to use the /bin/phpize tool in the installation directory later.
If you don't know where your php directory is installed, you can use the find command to find where the phpize file is.

Dynamically compile and add php module, compile php module_PHP tutorial

lfly@Dynamically compile and add php module, compile php module_PHP tutorial-oj9e:~> sudo find / -name phpize
Here I find that my php is installed under /php.

Okay, here I download a source code package of php-5.5.18.tar.gz.
After downloading, use tar -zxvf to decompress it. (Only for .tar.gz compressed packages)
Dynamically compile and add php module, compile php module_PHP tutorial

lfly@Dynamically compile and add php module, compile php module_PHP tutorial-oj9e:~/temp> tar -zxvf php-5.5.18.tar.gz

After decompression, you will get a php-5-5-18 folder
Then cd into the ext directory inside that directory:
lfly@Dynamically compile and add php module, compile php module_PHP tutorial-oj9e:~/temp> cd php-5.5.18/ext
Dynamically compile and add php module, compile php module_PHP tutorial

You can see many folders after using the ls command to list files:

Dynamically compile and add php module, compile php module_PHP tutorial

These are the source directories of the modules you want to compile. Here I assume that what we want to compile is the mysql module, then we cd into the mysql directory. If you want to compile other modules, then cd into the corresponding module.

Dynamically compile and add php module, compile php module_PHP tutorial


lfly@Dynamically compile and add php module, compile php module_PHP tutorial-oj9e:~/temp/php-5.5.18/ext/mysql> /php/bin/phpize
After Cd is entered, we call the phpize script mentioned above.
  
What is the Phpize script?
Mention it here:
Phpize can be understood as the role of reconnaissance environment. The phpize tool will generate the corresponding configure file based on the configuration of PHP you have installed.


After executing this command, you may be prompted that the autoconf program is not installed. If so, you must install the software before running this command.

I have no problem here:
Dynamically compile and add php module, compile php module_PHP tutorial

After Phpize runs without problems, use ./configure –with-php-config=/php/bin/php-config
Here /php/bin/php-config should be replaced with your Php installation directory. For example, if it is /usr/local/aaa, then you can set it to /usr/local/aaa/bin/php-config

If no error is reported after executing this step, execute the make command.

Dynamically compile and add php module, compile php module_PHP tutorial

If no error is reported when executing the make command, then execute the make install command.
Dynamically compile and add php module, compile php module_PHP tutorial

I found an error when making install here, because ordinary users do not have permission to install compiled modules into the PHP installation directory.
Dynamically compile and add php module, compile php module_PHP tutorial

At this time, you can use sudo to execute the make install command or directly switch to the root user for execution. You need to enter your password during execution.

After Make install is successfully installed, there are two things to do:

One is: Add a sentence in the php.ini configuration file:
Dynamically compile and add php module, compile php module_PHP tutorial0

extension=mysql.so
It is assumed here that the mysql module is compiled. If it is other, use other module names.
For example:
Dynamically compile and add php module, compile php module_PHP tutorial1

If you don’t know the name of the module you just compiled, you can check it in the module directory of php:
Dynamically compile and add php module, compile php module_PHP tutorial2

I have compiled and installed 4 modules here.

Note: Please indicate the source for reprinting: http://www.programfish.com/blog/?p=85

The second thing is to restart your apache. (If you install apache to provide web services)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/911074.htmlTechArticleDynamic compilation adds php module, compile php module Note: Please indicate the source for reprinting: http://www.programfish .com/blog/?p=85 In many cases when we build a web server in Linux, we need...
Statement:
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