Home  >  Article  >  Backend Development  >  Graphic tutorial for compiling and installing php5.6 under centos7

Graphic tutorial for compiling and installing php5.6 under centos7

黄舟
黄舟Original
2018-05-12 16:35:294501browse

1. Download the PHP installation package

wget http://php.net/distributions/php-5.6.31.tar.gz

By default, there is no connection between Nginx and PHP. Apache+PHP generates module files after compilation, while Nginx+PHP requires PHP to generate executable files, so fastcgi technology must be used to integrate Nginx and PHP. This only needs to be enabled during installation. FastCGI can be used. This time we installed PHP not only using FastCGI, but also using something like PHP-FPM. To put it bluntly, PHP-FPM is a manager for managing FastCGI. It exists as a plug-in for PHP. If you want to use it when installing PHP PHP-FPM needs to install PHP-FPM into PHP in the form of a patch, and PHP must be consistent with the PHP-FPM version. This is a must, remember!

2. Unzip and install

tar -zxvf php-5.6.31.tar.gz
cd php-5.6.3
./configure   
--prefix=/usr/local/php  
 --with-config-file-path=/usr/local/php/etc  
 --with-png-dir=/usr/local/libpng  
  --with-jpeg-dir=/usr/local/jpeg  
  --with-freetype-dir=/usr/local/freetype   
  --with-zlib-dir=/usr/local/zlib   
  --with-mcrypt=/usr/local/libmcrypt   
  --with-libxml-dir=/usr/local/libxml2/  
   --with-iconv-dir=/usr/local/libiconv   
   --enable-libxml   
   --enable-xml   
   --enable-bcmath   
   --enable-shmop  
    --enable-sysvsem  
     --enable-inline-optimization  
      --enable-opcache   
      --enable-mbregex   
      --enable-fpm   
      --enable-mbstring=all   
      --enable-gd-native-ttf   
      --with-openssl   
      --enable-pcntl   
      --enable-sockets   
      --with-xmlrpc   
      --enable-zip   
      --enable-soap  
       --without-pear  
        --with-gettext   
        --enable-session   
        --with-curl   
        --enable-ctype   
        --enable-shared   
        --with-gd

The following error was reported during the installation process:

It turns out that the plug-in gcc is not installed.

Continue installation:

yum install gcc

After the plug-in is installed, we continue to install PHP

Finally the following error is reported:

The libxml2 plug-in is not installed. Because my system is a newly installed centos system, various dependency packages will be missing. Continue to install the libxml2 plug-in:

yum install libxml2

Tips:

libxml2 already exists, maybe libxml2-dev is not installed, we install libxml2-devel

yum install libxml2-devel

After installation, we continue to install PHP, and another prompt:

We

We install the openssl plug-in

yum install openssl openssl-devel

After the installation is complete, we continue to install PHP and report confirmation Plug-in liburl

Install liburl

yum -y install curl-devel

After installation, continue to install PHP. It reports that the GD library is not installed. Let’s continue to install the GD library

yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel -y

Continue to install PHP reported missing plug-in libmcrypt

##centos tried to use yum to install libmcrypt unsuccessfully, and can only use compilation and installation:

#使用wget可以通过以下路径下载  
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz  
   
#解压  
tar -zxvf libmcrypt-2.5.7.tar.gz   
   
#进入目录  
cd libmcrypt-2.5.7  
   
#编译(默认安装到/usr/local/lib/)  
./configure --prefix=/usr/local/libmcrypt  
   
#执行安装  
make && make install

After the installation is complete, continue to install PHP. This time it finally prompts that the installation is successful:

Compile and install:

make && make install

3. Configuration

Copy php.ini-development in the source code to the PHP directory and rename it to PHP.ini

cp php.ini-development /usr/local/php/etc/php.ini

Copy a php-fpm configuration file and name it php-fpm. conf (under the path /usr/local/php/etc)

cp php-fpm.conf.default php-fpm.conf

Start php-fpm

/usr/local/php/sbin/php-fpm

If you find it troublesome to open the directory, you can set the startup script of php-fpm

cp php-5.6.31/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

When starting, just enter

#启动
service php-fpm start

#停止
service php-fpm stop

#重启
service php-fpm reload

4. Summary

It is not easy to compile and install PHP. To summarize:

The dependency packages that must be installed in advance to install PHP are :

gcc, libxml2, openssl, curl, libmcrypt, but everyone’s environment is different, and there may be different missing plug-ins. You can install them one by one according to the prompts.

The above is the detailed content of Graphic tutorial for compiling and installing php5.6 under centos7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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