Home Backend Development PHP Problem How to compile and install php5.6 php-fpm

How to compile and install php5.6 php-fpm

Dec 17, 2021 am 11:16 AM

php5.6 php-fpm compilation and installation method: 1. Install the php dependency package and download the php5.6.36 version; 2. Specify the software installation directory as "/usr/local/php"; 3. Perform nginx Just configure and parse php.

How to compile and install php5.6 php-fpm

The operating environment of this article: ubuntu16.04 system, php5.6.36 version, Dell G3 computer.

php5.6 php-fpm nginx installation and configuration

Today I found a website based on the php version, and then I went online to collect information and installed it again. try.
1. First install the php dependency package.

1

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gd gd2 gd-devel gd2-devel perl-CPAN pcre-devel

Copy after login

2. Download the php5.6.36 version

1

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

Copy after login

php-fpm component description

nginx in the LNMP environment does not support php, you need Process PHP requests through the fastcgi plug-in. PHP requires the php-fpm component to provide this function. In versions before php5.3.3, php-fpm existed in the form of a patch package. After php5.3.3, you only need to use --enable-fpm to load the module during compilation and installation, without installing it separately.

3. Install php

First create the directory where php needs to be installed

1

2

3

4

5

6

cd /etc/

mkdir php

cd /usr/local/

mkdir php

tar -xzvf php-5.6.36.tar.gz

cd php-5.6.36

Copy after login

In the following configuration, specify the software installation directory as /usr/local/php , the configuration file installation directory is

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

/etc/php

./configure --prefix=/usr/local/php --with-config-file-path=/etc/php --enable-fpm --enable-pcntl --enable-mysqlnd --enable-opcache --enable-sockets --enable-sysvmsg --enable-sysvsem  --enable-sysvshm --enable-shmop --enable-zip --enable-ftp --enable-soap --enable-xml --enable-mbstring --disable-rpath --disable-debug --disable-fileinfo --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pcre-regex --with-iconv --with-zlib --with-gd --with-openssl --with-mhash --with-xmlrpc --with-curl --with-imap-ssl

 

 

Thank you for using PHP.

config.status: creating php5.spec

config.status: creating main/build-defs.h

config.status: creating scripts/phpize

config.status: creating scripts/man1/phpize.1

config.status: creating scripts/php-config

config.status: creating scripts/man1/php-config.1

config.status: creating sapi/cli/php.1

config.status: creating sapi/fpm/php-fpm.conf

config.status: creating sapi/fpm/init.d.php-fpm

config.status: creating sapi/fpm/php-fpm.service

config.status: creating sapi/fpm/php-fpm.8

config.status: creating sapi/fpm/status.html

config.status: creating sapi/cgi/php-cgi.1

config.status: creating ext/phar/phar.1

config.status: creating ext/phar/phar.phar.1

config.status: creating main/php_config.h

config.status: executing default commands

 

 

[root@localhost php-5.6.36]# make

[root@localhost php-5.6.36]# make install

Copy after login

View the contents of the software installation directory

1

2

[root@localhost php-5.6.30]# ls /usr/local/php

bin  etc  include  lib  php  sbin  var

Copy after login

Copy the configuration file template to the configuration file directory

1

[root@localhost php-5.6.30]# cp php.ini-development /etc/php/php.ini

Copy after login

Create a soft connection

1

2

3

[root@localhost ~]# ln -s /usr/local/php/bin/php /usr/bin/php

[root@localhost ~]# ln -s /usr/local/php/bin/phpize /usr/bin/phpize

[root@localhost ~]# ln -s /usr/local/php/sbin/php-fpm /usr/bin/php-fpm

Copy after login

Check the installed version

1

2

3

4

5

6

7

8

9

10

11

[root@localhost ~]# /usr/local/php/bin/php --version

[root@localhost ~]# cd /usr/local/php/etc/

[root@localhost ~]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

[root@localhost ~]# ln -s /usr/local/php/etc/php-fpm.conf /etc/php/php-fpm.conf #添加软连接到 /etc/php目录

[root@localhost ~]# vim /usr/local/php/etc/php-fpm.conf

pid = run/php-fpm.pid #取消前面的分号

[root@localhost ~]# cp 源码目录/php-5.6.36/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #拷贝php-fpm到启动目录

  

[root@localhost ~]# chmod +x /etc/rc.d/init.d/php-fpm #添加执行权限

  

[root@localhost ~]# chkconfig php-fpm on #设置开机启动

Copy after login

Check whether the port is occupied

1

[root@localhost ~]# netstat -tunlp |grep 9000

Copy after login

Start the service

1

2

3

4

[root@localhost ~]# cd /etc/rc.d/init.d/

[root@localhost ~]# ./php-fpm start

[root@localhost ~]# netstat -tunlp |grep 9000

[root@localhost ~]# ps -ef|grep fpm

Copy after login

Four , nginx configuration parsing php

1. Enter the nginx directory

1

[root@localhost ~]# cd /usr/local/nginx/conf

Copy after login

2. Edit the configuration file

1

[root@localhost ~]# vim nginx.conf

Copy after login

and find it under server

1

2

3

4

5

6

location / {

    root html;

    index index.html index.htm

index.php

;    #加上index.php,让nginx服务器默认支持index.php为首页

}

Copy after login

Configure below. The php request is sent to the back-end php-fpm module. By default, the php configuration block is commented. At this time, remove the comment and modify it to the following content:

1

2

3

4

5

6

7

8

9

       location ~ \.php$ {

            root /usr/local/nginx/html;   #修改html路径

            fastcgi_pass 127.0.0.1:9000;

            fastcgi_index index.php;

       fastcgi_param SCRIPT_FILENAME

$document_root

$fastcgi_script_name;   #这里原来是/scripts,需要改成$document_root

            include fastcgi_params;

        }

Copy after login

Reload nginx after saving

1

2

3

[root@localhost ~]# /usr/local/nginx/nginx -s t

[root@localhost ~]# /usr/local/nginx/nginx -s reload

http://192.168.1.11/index.php

Copy after login



5. Related queries
1. Use the command to check how many php-cgi processes are opened on the server

1

ps -fe |grep "php-fpm"|grep "pool"|wc -l

Copy after login

2. Check how many php-cgi processes are used to handle tcp requests

1

netstat -anp|grep "php-fpm"|grep "tcp"|grep "pool"|wc -l

Copy after login

3. In the linux nginx php environment, each php-fpm process Memory limit

Setting method:

Edit the php-fpm.conf configuration file
php_admin_value[memory_limit] = 128M (the configuration file on my server is in /etc/php5/fpm/pool .d/www.conf This file is included in php-fpm.conf) The following numbers can be changed at will: 32M, 64M, 128M, 256M, 512M. This setting can be based on the memory size of your server and your needs. To write, you need to load the php-fpm service after modification

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to compile and install php5.6 php-fpm. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

OWASP Top 10 PHP: Describe and mitigate common vulnerabilities. OWASP Top 10 PHP: Describe and mitigate common vulnerabilities. Mar 26, 2025 pm 04:13 PM

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

PHP 8 JIT (Just-In-Time) Compilation: How it improves performance. PHP 8 JIT (Just-In-Time) Compilation: How it improves performance. Mar 25, 2025 am 10:37 AM

PHP 8's JIT compilation enhances performance by compiling frequently executed code into machine code, benefiting applications with heavy computations and reducing execution times.

PHP Secure File Uploads: Preventing file-related vulnerabilities. PHP Secure File Uploads: Preventing file-related vulnerabilities. Mar 26, 2025 pm 04:18 PM

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

PHP Encryption: Symmetric vs. asymmetric encryption. PHP Encryption: Symmetric vs. asymmetric encryption. Mar 25, 2025 pm 03:12 PM

The article discusses symmetric and asymmetric encryption in PHP, comparing their suitability, performance, and security differences. Symmetric encryption is faster and suited for bulk data, while asymmetric is used for secure key exchange.

PHP Authentication & Authorization: Secure implementation. PHP Authentication & Authorization: Secure implementation. Mar 25, 2025 pm 03:06 PM

The article discusses implementing robust authentication and authorization in PHP to prevent unauthorized access, detailing best practices and recommending security-enhancing tools.

PHP API Rate Limiting: Implementation strategies. PHP API Rate Limiting: Implementation strategies. Mar 26, 2025 pm 04:16 PM

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

PHP Input Validation: Best practices. PHP Input Validation: Best practices. Mar 26, 2025 pm 04:17 PM

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

PHP CSRF Protection: How to prevent CSRF attacks. PHP CSRF Protection: How to prevent CSRF attacks. Mar 25, 2025 pm 03:05 PM

The article discusses strategies to prevent CSRF attacks in PHP, including using CSRF tokens, Same-Site cookies, and proper session management.

See all articles