I often need to compile and install PHP myself in the Linux environment. There are many configure parameters. Sometimes I have to recompile PHP when I use it without paying attention, so the commonly used configure commands are organized as follows.
The first step is to install the dependent package:
yum -y install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel libaio
To install the mcrypt extension, you can use the command:
yum install libmcrypt-devel
Then use the command:
yum install php-mcrypt
The mcrypt extension is successfully installed.
Second step, install php:
cd /tmp wget http://cn2.php.net/get/php-5.5.10.tar.gz/from/cn2.php.net/mirror tar -zxvf mirror cd ./php-5.5.10
Then execute the command:
./configure \ --prefix=/usr/local/php5 \ --with-config-file-path=/usr/local/php5/etc \ --with-bz2 \ --with-curl \ --enable-ftp \ --enable-sockets \ --disable-ipv6 \ --with-gd \ --with-jpeg-dir=/usr/local \ --with-png-dir=/usr/local \ --with-freetype-dir=/usr/local \ --enable-gd-native-ttf \ --with-iconv-dir=/usr/local \ --enable-mbstring \ --enable-calendar \ --with-gettext \ --with-libxml-dir=/usr/local \ --with-zlib \ --with-pdo-mysql=mysqlnd \ --with-mysqli=mysqlnd \ --with-mysql=mysqlnd \ --enable-dom \ --enable-xml \ --with-libdir=lib64 \ --enable-pdo \ --enable-fpm \ --enable-mcrypt
The compilation process may report the following error:
checking for known struct flock definition… configure: error: Don’t know how to define struct flock on this system, set –enable-opcache=no
The solution is:
yum groupinstall "Development tools"
make make install
The above introduces the configure parameters and dependency packages of php-fpm that come with Linux source code compilation of php5.4 and above, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.