How to install PHP7 under centos7?

coldplay.xixi
Release: 2023-02-17 16:40:01
forward
4549 people have browsed it

The added library file path must be consistent with the system platform arch. For 32bit systems, just add [/usr/local/lib] directly. For 64bit systems, add [/usr/local/lib64.] Otherwise The error will still be reported. This article will introduce in detail how to install PHP7 under centos7.

How to install PHP7 under centos7?

1. Official website installation method:

http://php.net/manual/zh /install.unix.nginx.php

Related learning recommendations:PHP Programming from beginner to master

2. Compile and install

1. Download php7

wget -O php7.tar.gz http://cn2.php.net/get/php-7.1.20.tar.gz/from/this/mirror

or download directly from the webpage

http://php.net/get/php-7.1.20.tar.gz/from/a/mirror

2. Unzip php7

tar -xvf php7.tar.gz

3. Enter the php directory

cd /usr/local/src/php-7.1.20

4. Install dependency packages

yum install 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
Copy after login

5. Compile configuration(If an error occurs, it is basically caused by the dependency files in the previous step not being installed)

./configure \ --prefix=/software/php \ --with-config-file-path=/etc \ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ --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
Copy after login

Error reporting

The most practical solution is as follows:

Problem:

1: wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
Copy after login
2: tar zxf libmcrypt-2.5.7.tar.gz
Copy after login
3: ./configure --prefix=/usr/local
Copy after login
4: make && make install
Copy after login

Problem: configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no

Solution: Solution:

vim /etc/ld.so.conf.d/local.conf
Copy after login

# Edit the library file

/usr/local/lib
Copy after login

# Add this line

ldconfig -v
Copy after login

# Make it take effect

Note:

The library file path added here must be consistent with your system platform arch, 32bit system directly Just add/usr/local/lib. For 64bit systems, you need to add/usr/local/lib64. Otherwise, an error will still be reported. I just added/usr/ local/libcould not be edited alive and well, but it was later changed to/usr/local/lib64.

6. Formal installation

make && make install

7. Configuration Environment variables

vi /etc/profile PATH=$PATH:/usr/local/php/bin export PATH source /etc/profile
Copy after login

8. Configure php-fpm

cp php.ini-production /usr/local/php/etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf cp sapi/fpm/init.d.php-fpm /usr/local/php/etc/php-fpm chmod +x /usr/local/php/etc/php-fpm ln /usr/local/php/etc/php.ini /etc/php.ini
Copy after login

9. Create www user

useradd www
Copy after login

10. Configure startup parameters

vim /usr/local/php/etc/php-fpm.d/www.conf pm.max_children = 500 pm.start_servers = 105 pm.min_spare_servers = 10 pm.max_spare_servers = 200
Copy after login

11.Start php-fpm

/usr/local/php/etc/php-fpm start 设置 php-fpm开机启动 cp /usr/local/src/php-5.5.14/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #拷贝php-fpm到启动目录 chmod +x /etc/rc.d/init.d/php-fpm #添加执行权限 chkconfig php-fpm on #设置开机启动 service php-fpm start pkill php-fpm 强制关闭
Copy after login

The above is the detailed content of How to install PHP7 under centos7?. 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
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!