PHP install extension

不言
Release: 2023-03-23 21:32:01
Original
34174 people have browsed it

This article mainly introduces PHP installation extensions, which has certain reference value. Now I share it with everyone. Friends in need can refer to it

1. PHP extension management

1. What is a php extension?

php extension is a function that is not supported by the php core, and then you can Extend the functions of PHP through extensions. Common extensions include MySQL, gb2, etc.

2. Check which extensions are installed in php

Method 1: Check through the phpinfo() function, The red boxes are all PHP extensions


Method 2: Execute the php -m command:


Method 3: Use PHP’s get_loaded_extensions() function

<?php
    print_r(get_loaded_extensions());
?>
Copy after login

The output of the above routine is similar to:

Array( [0] => xml [1] => wddx [2] => standard [3] => session [4] => posix [5] => ; pgsql [6] => pcre [7] => gd [8] => ftp [9] => db [10] => calendar [11] => bcmath)

Method 4: The extension_loaded function checks whether an extension has been loaded. If the extension specified by name has been loaded, it returns TRUE, otherwise it returns FALSE.

<?php
if (!extension_loaded(&#39;gd&#39;)) {
    if (!dl(&#39;gd.so&#39;)) {
        exit;
    }
}
?>
Copy after login

3.Manage php extensions

a. Set the directory where the extension is located, and set the extension_dir of php.ini to your own php extension path


b. Load the extension


2. Install php extension on windows

1. Download

http://pecl.php.net/ is the official extension library, we can download the extensions we want here


2. Select version

redis is installed For example:


##Click


Click the button to enter the windows download interface


You need to pay attention to the version when installing the php extension for windows Choices: PHP version, whether it is linear security, the number of operating systems.

3. Installation

Unzip the downloaded compressed package, and then put the php_redis.dll inside In the folder specified in php.ini, load the redis module, and then start the server.

3. Install php extension on linux

##1.yum or apt-get installation


2. Use pecl to install

1). pecl install installation

~# pecl install memcached

downloading memcached-2.2.0.tgz ...

Starting to download memcached-2.2.0.tgz (70,449 bytes)....

2), configure php.ini

Find the location of the php.ini file by running php --ini, and then add extension=memcached.so in the file

3.phpize installation— —Take redis as an example

1), download the php expansion package

[root@localhost ~]# wget http://pecl.php.net/get/redis-4.0.0.tgz

##2), unzip and enter the expansion package directory

[root@localhost ~]# tar -xzvvf

redis-4.0.0.tgz

[root@localhost

redis-4.0.0]#cd redis-4.0.0

3), execute phpize

[root@localhost

redis-4.0.0]# phpize##4), ./configure

[root@localhost

redis-4.0.0]#./configure --with-php-config=/ usr/bin/php-config

5), make && make install

[root@localhost redis-4.0.0]# make && make install

6), configure php.ini

extension=redis.so

##4. Direct installation (similar to windows)

#Direct download will download the compressed package. After decompression, put the file with .so suffix directly into the specified path. Then configure the php.ini file.

Related recommendations:

Installing redis extension for PHP under Windows

The above is the detailed content of PHP install extension. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!