Home > Backend Development > PHP7 > How to install php7 and install memcache extension. What should I do if there are compatibility issues between old and new php versions?

How to install php7 and install memcache extension. What should I do if there are compatibility issues between old and new php versions?

醉折花枝作酒筹
Release: 2023-02-18 07:26:01
forward
2548 people have browsed it

I don’t know if you will install php7, and I don’t know if you will deal with the compatibility issues between old and new php versions when installing the memcache extension. Today I will take you through it, and you can refer to it if you need it.

How to install php7 and install memcache extension. What should I do if there are compatibility issues between old and new php versions?

http://php.net/downloads.php

Install php-7.0.0

First install the dependent program if it is already If you have installed it, please skip it

yum install -y php-mcrypt libmcrypt libmcrypt-devel
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel
#openssl-devel是64位 如果是32位服务器请选择i386版的
yum install openssl-devel.x86_64
yum install curl curl-devel
yum -y install libxslt-devel
yum install -y php-mcrypt libmcrypt libmcrypt-devel mcrypt mhash
Copy after login
./configure --prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc \
--with-config-file-scan-dir=/usr/local/php7/etc/php.d \
--with-mcrypt \
--enable-mysqlnd \
--with-mysqli \
--with-pdo-mysql \
--enable-fpm \
--with-gd \
--with-iconv \
--with-zlib \
--enable-xml \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache

make &&  make install

可选
--with-fpm-user=www \
--with-fpm-group=www \
Copy after login

If you are prompted configure: error: mcrypt.h not found. Please reinstall libmcrypt.

Because the default yum source of centos6.x does not have the libmcrypt-devel package. Due to copyright reasons, you can only use third-party yum sources, or manually download and compile the installation package yourself

wget http://jaist.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
./configure
make && make install
Copy after login

If checking for C compiler default output file name... configure: error: C compiler

cannot create executables

yum list | grep c++
yum install gcc-c++.x86_64
Copy after login

If you are prompted with undefined reference to `libiconv', you need to install libiconv first

--with-iconv=/usr/local/libiconv
Copy after login

If you still get an error, vim Makefile

Find EXTRA_LIBS =

Add -liconv

at the end or directly make ZEND_EXTRA_LIBS='-liconv'

If you reinstall an old version of php, you need to recompile apache's LoadModule php5_module file

./configure --with-apxs2=/usr/local/sbin/apxs
Copy after login

At this point, the php7 installation is completed

mv /usr/local/src/php-7.1.0/php.ini-production /usr/local/php7/etc/php.ini
Copy after login

Enable php-fpm service

cd /usr/local/php7/etc
mv php-fpm.conf.default php-fpm.conf
mv php-fpm.d/www.conf.default php-fpm.d/www.conf
Copy after login

Be careful to change the user and group of php-fpm.conf, otherwise File not found may be reported due to permission issues.

user = nobody
group = nobody
Copy after login

Run php-fpm

/usr/local/php7/sbin/php-fpm -c /usr/local/php7/etc/php.ini -y /usr/local/php7/etc/php-fpm.conf
Copy after login

If you want to use this command service php-fpm start|stop|restart

cd /usr/local/src/php-7.1.0/sapi/fpm
ls
cp init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
Copy after login

you can use service php-fpm start to enable php- fpm. Use ps -ef | grep php-fpm to check the process.

But when I install the memcache extension

http://pecl.php.net/package/memcache

Install memcache-2.2.7 2012 stable version

#如果已安装过autoconf请忽略
autoconf
yum install autoconf

phpize
./configure --enable-memcache --with-php-config=/usr/local/php7/bin/php-config
make && make install
Copy after login

Fatal error reported at this time /root/memcache-2.2.7/memcache.c:40:40: fatal error: ext/standard/php_smart_str.h: No such file or directory

The php_smart_str.h file does not exist

Baidu search php_smart_string.h is to dynamically apply for memory space for string preprocessing. It is similar to the allocation of memory in pages in the operating system. Its advantage is to align memory addresses and improve access. speed.

I found that php7 has changed this file to php_smart_string.h. Comparing the two files, the changes are quite large.

I don’t know if this is because the compatibility of the official PHP development team has not been improved

Recommended learning: php video tutorial

The above is the detailed content of How to install php7 and install memcache extension. What should I do if there are compatibility issues between old and new php versions?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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