


Summary of ways to install extensions for PHP in CentOS systems
This article gives you a summary of the ways to install and expand PHP in CentOS systems, mainly including package-managed yum installation, pecl installation, and source code compilation and installation. The summary is very comprehensive and I recommend it to everyone.
CentOS
, PHP has many ways to install extensions, mainly package management
yum installation
, pecl installation
, and source code compilation and installation
.
Package management style
is particularly convenient for installation and uninstallation, while source code compilation style
installation is convenient for parameter tuning.
Generally recommended to build a local development environment Package management
installation to save time. For online deployment
environment, compile and install
is recommended for easy tuning.
This article uses the MongoDB
extension installation example.
Tools
PHP version: 7.0.17
Nginx: 1.10.2
VMware version number: 12.0.0
CentOS version: 7.0
1. yum installation
yum method
Install the .so dynamic library that can automatically install extensions. And configure php.ini
Note:
Please make sure that your yum source
has the corresponding extension
After the installation is completed Restart the server Nginx
or Apache
browser to access the index.php
file and output the phpinfo
information, if anyMongoDB
information, the installation is successful
[root@localhost ~]yum search mongodb|grep php # 搜索 yum 源里面 MongoDB 拓展 [root@localhost ~]yum -y install php70w-pecl-mongo # 安装 PHP 对应版本的 MongoDB 扩展 [root@localhost ~]systemctl restart nginx # 重新启动 Nginx
# #2. pecl installation
Official document: http://php.net/manual/zh/mong...[root@localhost ~]# pecl install mongodb -bash: pecl: 未找到命令Directly enter
pecl install mongodb and an error will be reported, indicating that
pecl we have not installed it, install
pecl
[root@localhost ~]# yum -y install php70w-pear [root@localhost ~]# pecl install mongodb configure: error: Cannot find OpenSSL's <evp.h> ERROR: `/var/tmp/mongodb/configure --with-php-config=/usr/bin/php-config' failedAt this step, another
error will be reported. We need to install
openssl. After the installation is completed, continue to execute the last
unsuccessfully executed command
[root@localhost ~]# yum -y install openssl openssl-devel [root@localhost ~]# pecl install mongodb [root@localhost ~]# systemctl restart nginx # 重新启动 NginxAfter the installation is complete, load it in the
PHP configuration file
php.iniMongoDB
Extension
##After installation is complete, restart the server
or Apache
browser Access the
file and output phpinfo
information. If there is MongoDB
information, the installation is successful
Source code compilation package download list: https://pecl.php.net/packages.php
Mongodb package download address: https: //pecl.php.net/package/mongodb
[root@localhost ~]# wget http://pecl.php.net/get/mongodb-1.2.8.tgz #下载源码包 [root@localhost ~]# tar zxf mongodb-1.2.8.tgz #解压 [root@localhost ~]# cd mongodb-1.2.8 # 可能是 /usr/local/php/bin/phpize 找到自己的 phpize 文件,php-config 同理 [root@localhost mongodb-1.2.8]# /usr/bin/phpize Configuring for: PHP Api Version: 20151012 Zend Module Api No: 20151012 Zend Extension Api No: 320151012 [root@localhost mongodb-1.2.8]# ./configure --with-php-config=/usr/bin/php-config configure: error: Cannot find OpenSSL's <evp.h>
At this point
It’s a familiar taste and a familiar feeling, We need to install openssl
. After the installation is completed, continue to execute the last unexecuted successfully
command
##
[root@localhost mongodb-1.2.8]# yum -y install openssl openssl-devel [root@localhost mongodb-1.2.8]# ./configure --with-php-config=/usr/bin/php-config # 确保自己安装了 gcc gcc++ 如果没有安装 yum -y install gcc gcc++ [root@localhost mongodb-1.2.8]# make && make install # 编译Description:
php-config
is a simple command line script used toobtain the installed
PHP configuration information.
When compiling an extension, if multiple PHP versions are installed, you can use the
--with-php-config
php-config script.
Compilation successful
At this time in the PHP
php.ini Load inside
MongoDB extension
Restart the serverNginx
Apache The browser accesses the
index.php
phpinfo information. If there is
MongoDB information, the installation is successful
[root@localhost mongodb-1.2.8]# systemctl restart nginx # 重新启动 Nginx
Summary: The difference between
pecl installation
andsource code compilation and installation is : The latter is more convenient for parameter tuning.
When choosing
Mongo extension
mongo and
mongodbThe first one: https://pecl.php.net/package/mongo
The first official tip: This package has been superseded, but is still maintained for bugs and security fixes
, has been abandoned, but bug
and security
Problems will continue to be fixed, and PHP7
is not supported.
Recommendation:
If PHP version is 5.x, it is recommended to use mongo
extension
If PHP version is 7.x, it is recommended to use mongodb
Extensions
PHP5.x can use the mongodb
extension. But PHP7.x cannot use the mongo
extension.
Written at the end:
If you are learning by yourself, it is still recommended to install with yum, because there will be
missing during your installation process Error reports for various dependencies
The above is the detailed content of Summary of ways to install extensions for PHP in CentOS systems. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Restartyourrouterandcomputertoresolvetemporaryglitches.2.RuntheNetworkTroubleshooterviathesystemtraytoautomaticallyfixcommonissues.3.RenewtheIPaddressusingCommandPromptasadministratorbyrunningipconfig/release,ipconfig/renew,netshwinsockreset,andnetsh

PHParrayshandledatacollectionsefficientlyusingindexedorassociativestructures;theyarecreatedwitharray()or[],accessedviakeys,modifiedbyassignment,iteratedwithforeach,andmanipulatedusingfunctionslikecount(),in_array(),array_key_exists(),array_push(),arr

TheObserverdesignpatternenablesautomaticnotificationofdependentobjectswhenasubject'sstatechanges.1)Itdefinesaone-to-manydependencybetweenobjects;2)Thesubjectmaintainsalistofobserversandnotifiesthemviaacommoninterface;3)Observersimplementanupdatemetho

$_COOKIEisaPHPsuperglobalforaccessingcookiessentbythebrowser;cookiesaresetusingsetcookie()beforeoutput,readvia$_COOKIE['name'],updatedbyresendingwithnewvalues,anddeletedbysettinganexpiredtimestamp,withsecuritybestpracticesincludinghttponly,secureflag

To effectively protect phpMyAdmin, multiple layers of security measures must be taken. 1. Restrict access through IP, only trusted IP connections are allowed; 2. Modify the default URL path to a name that is not easy to guess; 3. Use strong passwords and create a dedicated MySQL user with minimized permissions, and it is recommended to enable two-factor authentication; 4. Keep the phpMyAdmin version up to fix known vulnerabilities; 5. Strengthen the web server and PHP configuration, disable dangerous functions and restrict file execution; 6. Force HTTPS to encrypt communication to prevent credential leakage; 7. Disable phpMyAdmin when not in use or increase HTTP basic authentication; 8. Regularly monitor logs and configure fail2ban to defend against brute force cracking; 9. Delete setup and

XSLT parameters are a key mechanism for dynamic conversion through external passing values. 1. Use declared parameters and set default values; 2. Pass the actual value from application code (such as C#) through interfaces such as XsltArgumentList; 3. Control conditional processing, localization, data filtering or output format through $paramName reference parameters in the template; 4. Best practices include using meaningful names, providing default values, grouping related parameters, and performing value verification. The rational use of parameters can make XSLT style sheets highly reusable and maintainable, and the same style sheets can produce diversified output results based on different inputs.
![You are not currently using a display attached to an NVIDIA GPU [Fixed]](https://img.php.cn/upload/article/001/431/639/175553352135306.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
Ifyousee"YouarenotusingadisplayattachedtoanNVIDIAGPU,"ensureyourmonitorisconnectedtotheNVIDIAGPUport,configuredisplaysettingsinNVIDIAControlPanel,updatedriversusingDDUandcleaninstall,andsettheprimaryGPUtodiscreteinBIOS/UEFI.Restartaftereach

APIversioninginPHPcanbeeffectivelyimplementedusingURL,header,orqueryparameterapproaches,withURLandheaderversioningbeingmostrecommended.1.ForURL-basedversioning,includetheversionintheroute(e.g.,/v1/users)andorganizecontrollersinversioneddirectories,ro
