centos7 compile and install php7.4

1. Download and install compilation tools

yum groupinstall 'Development Tools'

2. Installation dependencies

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 zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel

3. Download and unzip php7.4

wget http://php.net/distributions/php-7.4.0.tar.gz
tar -zxvf php-7.4.0.tar.gz 
cd php-7.4.0

4. Compile mounting (./configure --help view translation parameters)

 Before compiling the new user groups, users, compiled for use

groupadd www
useradd -g www www

Start compiling (according to their need to increase or decrease)

./configure \ 
--prefix=/usr/local/php \ 
--with-config-file-path=/etc \ 
--with-fpm-user=www \ 
--with-fpm-group=www \  
--with-curl \ 
--with-freetype-dir \ 
--enable-gd \ 
--with-gettext \  
--with-iconv-dir \ 
--with-kerberos \ 
--with-libdir=lib64 \ 
--with-libxml-dir \ 
--with-mysqli \ 
--with-openssl \ 
--with-pcre-regex \ 
--with-pdo-mysql \ 
--with-pdo-sqlite \ 
--with-pear \ 
--with-png-dir \ 
--with-jpeg-dir \ 
--with-xmlrpc \ 
--with-xsl \ 
--with-zlib \ 
--with-bz2 \ 
--with-mhash \ 
--enable-fpm \ 
--enable-bcmath \ 
--enable-libxml \ 
--enable-inline-optimization \ 
--enable-mbregex \ 
--enable-mbstring \ 
--enable-opcache \ 
--enable-pcntl \ 
--enable-shmop \ 
--enable-soap \ 
--enable-sockets \ 
--enable-sysvsem \ 
--enable-sysvshm \ 
--enable-xml \  
--enable-zip \ 
--enable-fpm

It should be noted that in php7.4 translation parameters --with-gd wanted to change the --enable-gd

当报错checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11

# Delete the old version of 
yum the Remove - the y-libzip 

# Download compile and install 
wget HTTPS: // nih.at/libzip/libzip-1.2.0.tar.gz 
tar -zxvf libzip- 1.2 . 0 .tar.gz 
cd libzip - 1.2 . 0 
. / the configure 
the make && the make install

error: Package requirements (sqlite3 > 3.7.4) were not met

yum install libsqlite3x-devel -y

error: Package requirements (oniguruma) were not met

yum install oniguruma-devel -y

 When yum install prompt "No available packages"

yum install -y epel-release

off_t undefined error

configure: error: off_t undefined; check your library configuration

off_t unistd.h type defined in the header file,
the system 32 is programmed to long int, 64-bit system is compiled into long long int,
is performed to find the translation of the default 64-bit dynamic link library,
but by default dynamic link library configuration file /etc/ld.so.conf under centos's did not join the search path,
this time you need to / usr / local / lib64 / usr / lib64 library path for these 64 added to the list.

# Add search path to the configuration file 
echo ' / usr / local / lib64 
/ usr / local / lib
 / usr / lib
 / usr / lib64 ' >> / etc / ld.so.conf 

# then update the configuration 
ldconfig -v

/usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory

cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

Compiler no problem, do make && make install installation

5. Configuration Environment

After installing the command execution php7.4 it has been installed into usr / local under / / php directory of

/usr/local/php/bin/php -v

View version

Adding Environment Variables

vim /etc/profile

Adding to the last

PATH=$PATH:/usr/local/php/bin
export PATH

Updating environment variables

source /etc/profile

View version

php -v

6. Configure php-fpm

cp php.ini-production / 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 cow /fpm/init.d.php-fpm /etc/init.d/php- fpm 
chmod + x /etc/init.d / php-fpm

Start php-fpm

/etc/init.d/php- FPM Start 
or 
Service PHP -fpm Start

Guess you like

Origin www.cnblogs.com/liubaoqing/p/12176017.html