search
HomeBackend DevelopmentPHP ProblemHow to compile and install php5.6 php-fpm

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.

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

2. Download the php5.6.36 version

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

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

cd /etc/
mkdir php
cd /usr/local/
mkdir php
tar -xzvf php-5.6.36.tar.gz
cd php-5.6.36

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

/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

View the contents of the software installation directory

[root@localhost php-5.6.30]# ls /usr/local/php
bin  etc  include  lib  php  sbin  var

Copy the configuration file template to the configuration file directory

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

Create a soft connection

[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

Check the installed version

[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 #设置开机启动

Check whether the port is occupied

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

Start the service

[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

Four , nginx configuration parsing php

1. Enter the nginx directory

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

2. Edit the configuration file

[root@localhost ~]# vim nginx.conf

and find it under server

location / {
    root html;
    index index.html index.htm 
index.php
;    #加上index.php,让nginx服务器默认支持index.php为首页
}

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:

       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;
        }

Reload nginx after saving

[root@localhost ~]# /usr/local/nginx/nginx -s t
[root@localhost ~]# /usr/local/nginx/nginx -s reload
http://192.168.1.11/index.php



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

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

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

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

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
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
ACID vs BASE Database: Differences and when to use each.ACID vs BASE Database: Differences and when to use each.Mar 26, 2025 pm 04:19 PM

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

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 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 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 Password Hashing: password_hash and password_verify.PHP Password Hashing: password_hash and password_verify.Mar 26, 2025 pm 04:15 PM

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

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 XSS Prevention: How to protect against XSS.PHP XSS Prevention: How to protect against XSS.Mar 26, 2025 pm 04:12 PM

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

PHP Interface vs Abstract Class: When to use each.PHP Interface vs Abstract Class: When to use each.Mar 26, 2025 pm 04:11 PM

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment