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

Graphic tutorial for compiling and installing php5.6 under centos7

黄舟
Release: 2023-03-14 19:36:02
Original
4515 people have browsed it

1. Download the PHP installation package

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

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

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

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

Tips:

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

yum install libxml2-devel
Copy after login

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

We

We install the openssl plug-in

yum install openssl openssl-devel
Copy after login

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

Install liburl

yum -y install curl-devel
Copy after login

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

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

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

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 after login

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

Start php-fpm

/usr/local/php/sbin/php-fpm
Copy after login

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

When starting, just enter

#启动
service php-fpm start

#停止
service php-fpm stop

#重启
service php-fpm reload
Copy after login
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!

Related labels:
source:php.cn
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