Yum php7.1 method to add extensions: 1. Install php7.1 through yum; 2. Add through the "yum -y install php-mysql php-gd php-ldap php-odbc..." command Common PHP extensions are enough.
The operating environment of this article: centos7 system, PHP7.1 version, DELL G3 computer
How to add extensions to yum php7.1?
Tutorial on how to deploy php7.1 under CentOS 7 and enable MySQL extension
Preface
Previously installed php7.1 on CentOS7 Sometimes I encountered the problem that the PHP source and PHP7.1 did not support the MySQL extension. I took the time to install it in the morning and finally solved these two problems. I hereby record the memo.
Simple installation (yum method)
Install software source
Add epel source
[root@opstrip.com opt]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY* [root@opstrip.com opt]# rpm -Uvh http://mirrors.rit.edu/fedora/epel//7/x86_64/e/epel-release-7-9.noarch.rpm
Add remi source
[root@opstrip.com opt]# rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Install and update Software
Install the yum-config-manager utility
[root@opstrip.com opt]# yum -y install yum-utils
Update the current software version of the system
[root@opstrip.com opt]# yum -y update
After the update is completed, you can install the required PHP version.
Install PHP
After the above preparations are completed, you can install the required PHP version.
For PHP5.4
[root@opstrip.com opt]# yum -y install php
Before installation, you can try yum search php54 to search for installable software packages.
For PHP7.0
[root@opstrip.com opt]# yum-config-manager --enable remi-php70 [root@opstrip.com opt]# yum -y install php php-opcache
Before installation, you can try yum search php70 to search for installable software packages.
For PHP7.1
[root@opstrip.com opt]# yum-config-manager --enable remi-php71 [root@opstrip.com opt]# yum -y install php php-opcache
Before installation, you can try yum search php71 to search for installable software packages.
After completion, you need to add common PHP extensions:
[root@opstrip.com opt]# yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel
For Nginx
[root@opstrip.com opt]# yum -y install nginx nginx-mod-http-perl nginx-mod-stream nginx-filesystem nginx-mod-mail nginx-mod-http-image-filter nginx-all-modules nginx-mod-http-geoip nginx-mod-http-xslt-filter
It is still recommended to try yum search nginx to search for installable software packages before installation.
After the installation is complete, configure PHP and Nginx and start it to test the phpinfo page. It should be displayed normally at this time.
Source code compilation and installation
Preparation before installation
Download PHP installation package
[root@opstrip.com opt]# wget -O php-7.1.5.tar.gz http://cn2.php.net/distributions/php-7.1.5.tar.gz
Unzip
[root@opstrip.com opt]# tar xf php-7.1.5.tar.gz
Install dependency package
[root@opstrip.com php-7.1.5]# yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
Configuration and installation
Compilation configuration
[root@opstrip.com opt]# cd php-7.1.5 [root@opstrip.com php-7.1.5]# ./configure \ --prefix=/usr/local/php \ --with-config-file-path=/etc \ --enable-fpm \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-soap \ --with-libxml-dir \ --with-xmlrpc \ --with-openssl \ --with-mcrypt \ --with-mhash \ --with-pcre-regex \ --with-sqlite3 \ --with-zlib \ --enable-bcmath \ --with-iconv \ --with-bz2 \ --enable-calendar \ --with-curl \ --with-cdb \ --enable-dom \ --enable-exif \ --enable-fileinfo \ --enable-filter \ --with-pcre-dir \ --enable-ftp \ --with-gd \ --with-openssl-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib-dir \ --with-freetype-dir \ --enable-gd-native-ttf \ --enable-gd-jis-conv \ --with-gettext \ --with-gmp \ --with-mhash \ --enable-json \ --enable-mbstring \ --enable-mbregex \ --enable-mbregex-backtrack \ --with-libmbfl \ --with-onig \ --enable-pdo \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-zlib-dir \ --with-pdo-sqlite \ --with-readline \ --enable-session \ --enable-shmop \ --enable-simplexml \ --enable-sockets \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-wddx \ --with-libxml-dir \ --with-xsl \ --enable-zip \ --enable-mysqlnd-compression-support \ --with-pear \ --enable-opcache
For details, please refer to the official PHP installation instructions document: http://php.net/manual/zh/install.unix.nginx.php
Compile and install
[root@opstrip.com php-7.1.5]# make && make install
Configure environment variables:
Append export PATH=$PATH:/usr/local/php/bin at the end of /etc/profile, and then execute source / Check the php version after etc/profile takes effect:
[root@opstrip.com php-7.1.5]# php -v PHP 7.1.5 (cli) (built: May 31 2017 16:12:38) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
Configuration after installation
Configuration php-fpm
After the installation is completed, you can use sapi/fpm/php-fpm.server Let’s start php-fpm. However, for the convenience of future management, it is usually necessary to place the configuration files in the /etc directory and add php-fpm.server to the systemctl service. As follows:
[root@opstrip.com php-7.1.5]# mkdir -p /etc/php-fpm.d [root@opstrip.com php-7.1.5]# cp php.ini-production /etc/php.ini [root@opstrip.com php-7.1.5]# cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/ [root@opstrip.com php-7.1.5]# cp sapi/fpm/www.conf /etc/php-fpm.d/
Then change the /usr/lib/systemd/system/php-fpm.service file to execute the correct path, as follows:
[root@opstrip.com php-7.1.5]# vi /usr/lib/systemd/system/php-fpm.service # It's not recommended to modify this file in-place, because it # will be overwritten during upgrades. If you want to customize, # the best way is to use the "systemctl edit" command. [Unit] Description=The PHP FastCGI Process Manager After=network.target [Service] Type=simple PIDFile=/var/run/php-fpm.pid ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /etc/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
Start php-fpm
When starting the PHP service through systemctl for the first time, you need to enable the php-fpm service first:
[root@opstrip.com php-7.1.5]# systemctl enable php-fpm.service [root@opstrip.com php-7.1.5]# systemctl start php-fpm.service
Compile and install Nginx
See this article for details, and configure and start Nginx as needed. I won’t write it down here.
Enable MySQL extension (only compile and install)
Since PHP7 has completely removed MySQL extension support (replaced by mysqli and mysqlnd), some old software will If an error similar to that the mysql_connect() function is not defined is reported, it is generally recommended to use the new PHPmysqli or pdo extension to replace it. Of course, you can also check out the legacy version of the PHP7 code that supports the MySQL extension and compile and install it yourself. However, it should be noted that the MySQL extension has no subsequent updates at all.
Preparation before installation
View the current extension
Check the current PHP7.1 built-in extension:
[root@opstrip.com php-7.1.5]# ls ext bcmath dom gd json oci8 pdo_firebird posix skeleton sysvsem xmlwriter bz2 enchant gettext ldap odbc pdo_mysql pspell snmp sysvshm xsl calendar exif gmp libxml opcache pdo_oci readline soap tidy zip com_dotnet ext_skel hash mbstring openssl pdo_odbc recode sockets tokenizer zlib ctype ext_skel_win32.php iconv mcrypt pcntl pdo_pgsql reflection spl wddx curl fileinfo imap mysql pcre pdo_sqlite session sqlite3 xml date filter interbase mysqli pdo pgsql shmop standard xmlreader dba ftp intl mysqlnd pdo_dblib phar simplexml sysvmsg xmlrpc
You can see that the MySQL extension has indeed been removed Now, we can directly check out the old PHP MySQL extension code in the ext directory.
Get the PHP MySQL extension source code
[root@opstrip.com ext]# git clone https://github.com/php/pecl-database-mysql mysql --recursive Cloning into 'mysql'... remote: Counting objects: 145, done. remote: Total 145 (delta 0), reused 0 (delta 0), pack-reused 145 Receiving objects: 100% (145/145), 88.41 KiB | 0 bytes/s, done. Resolving deltas: 100% (65/65), done. Checking connectivity... done.
Compile and install the MySQL extension
Compile using phpize
[root@opstrip.com ext]# cd mysql [root@opstrip.com mysql]# ls config.m4 config.w32 CREDITS LICENSE mysql.mak mysql_mysqlnd.h package.xml php_mysql.c php_mysql.h php_mysql_structs.h README.md tests [root@opstrip.com mysql]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20151012 Zend Module Api No: 20151012 Zend Extension Api No: 320151012 [root@opstrip.com mysql]# ./configure --with-php-config=/usr/local/php/bin/php-config
Installation
[root@opstrip.com mysql]# make && make install [root@opstrip.com mysql]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/ mysql.so opcache.a opcache.so
Required after the installation is complete Confirm whether the MySQL extension is installed correctly.
Finally modify the php.ini configuration file and add a line:
extension = "mysql.so"
Restart the php-fpm service and you will see the MySQL extension in phpinfo:
–This configuration is complete.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to add extensions to yum php7.1. For more information, please follow other related articles on the PHP Chinese website!

因为需要用到C++11,但CentOS自带的gcc4.4.7不支持,所以决定升级gcc。操作如下:#备份mv/etc/yum.repos.d/devtools-2.repo/etc/yum.repos.d/devtools-2.repo.bakwgethttp://people.centos.org/tru/devtools-2/devtools-2.repo-O/etc/yum.repos.d/devtools-2.repoyuminstalldevtoolset-2-gccdevtoolse

1.下载gitlab安装包从【清华大学开源软件镜像站】下载最新中文版gitlab安装包,安装包里自带了简体中文汉化包。从【gitlab官网】下载gitlab最新安装包。2.安装gitlab以gitlab-ce-14.9.4-ce.0.el7.x86_64为例,将其上传至centos服务器使用yum安装gitlabyum-yinstallgitlab-ce-14.3.2-ce.0.el7.x86_64.rpm使用yum安装gityum-yinstallgit#安装git修改gitlab配置文件vi

一般来说著名的Linux系统基本上分两大类:RedHat系列:Redhat、Centos、Fedora等;Debian系列:Debian、Ubuntu等。yum(YellowdogUpdater,Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器。apt(AdvancedPackagingTool)是一个在Debian和Ubuntu中的Shell前端软件包管理器。概述一般来说著名的Linux系统基本上分两大类:RedHat系列:Redhat、Cento

centos7 yum删除php的方法:1、通过“php-v”查看PHP版本;2、使用“rpm -qa|grep php”查看已经安装的PHP相关扩展;3、通过执行“yum remove php”命令卸载php即可。

在linux中,yum是一个专门为了解决包的依赖关系而存在的软件包管理器;yum是改进型的RPM软件管理器,它很好的解决了RPM所面临的软件包依赖问题。当管理员使用yum安装RPM包时,yum会先从服务器端下载包的依赖性文件,通过分析此文件从服务器端一次性下载所有相关的RPM包并进行安装。

linux使用yum安装php的方法:1、执行“mkdir /usr/local/php”命令;2、下载yum源的更新安装包;3、安装相关yum源安装包;4、通过“yum install”命令安装php即可。

大家都或许熟悉Linux系统中的yum,但初学者可能对它并不了解。本文将介绍yum是什么,以及它的功能。请继续阅读。 在Linux中,yum是一个包管理器,用于管理和安装软件包。它是YellowdogUpdater,Modified的缩写,最初是为RedHat系列发行版设计的,但现在也被其他许多基于RPM的Linux发行版所采用。 YUM命令的主要功能包括:YUM是一种软件包管理工具,可用于查找、安装、更新和卸载软件包。通过YUM命令,用户可以方便地管理系统上的软件包,并自动解决软件包之间的

在CentOS7上安装和部署Docker非常简单,只需要几个简单的步骤即可完成。下面是详细的步骤和说明:更新系统在安装Docker之前,首先需要更新CentOS7操作系统。使用以下命令可以更新系统:sudoyumupdate安装必要的软件包在CentOS7上安装Docker需要安装一些必要的软件包,包括yum-utils、device-mapper-persistent-data和lvm2。使用以下命令安装这些软件包:sudoyuminstall-yyum-utilsdevice-mapper-


Hot AI Tools

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

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

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Linux new version
SublimeText3 Linux latest version

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
