Home Backend Development PHP Problem How to compile and install PHP-FPM from source code

How to compile and install PHP-FPM from source code

Apr 12, 2023 am 09:03 AM

With the popularity and use of PHP, PHP-FPM is also known and used by more and more users and developers. Because PHP-FPM comes with more advanced process management and reloading tools, it is widely used in PHP programs in high-traffic and HTTP high-concurrency scenarios.

This article will explain how to compile and install PHP-FPM from source code, and explain it step by step. I believe that after reading the article, readers will easily and quickly install PHP-FPM for their systems to better adapt to various application scenarios.

1. Notes

Before installing PHP-FPM, you need to pay attention to the following:

1. Confirm the required system dependencies (including runtime and Dependencies during build);
2. Select the required PHP-FPM version, it is recommended to choose the latest version;
3. Unzip the source code of PHP-FPM;
4. Compile PHP-FPM and install ;
5. You need to know some configuration file parameters and command line options.

2. Installation environment

Before starting the installation, please confirm your operating system and the version of PHP-FPM you need to install. In this article, we will choose PHP-FPM-7.4.12 version and use CentOS 7 operating system.

3. Confirm the required system dependencies

To install PHP-FPM on CentOS 7, you need to install some system dependencies first. The following are the dependencies we need to install:

1. Install GCC and make compiler;
2. Install OpenSSL and OpenSSL-devel;
3. Install libxml2 and libxml2-devel;
4. Install bzip2 and bzip2-devel;
5. Install libjpeg and libjpeg-devel;
6. Install libpng and libpng-devel;
7. Install libmcrypt and libmcrypt-devel;
8 .Install zlib and zlib-devel;
9.Install libzip and libzip-devel.

Please follow the steps below to install the required dependencies:

1. Use yum to install GCC and make compiler:

sudo yum -y install gcc make

2. Install OpenSSL and OpenSSL-devel:

sudo yum -y install openssl openssl-devel

3. Install libxml2 and libxml2-devel:

sudo yum -y install libxml2 libxml2-devel

4. Install bzip2 and bzip2-devel:

sudo yum -y install bzip2 bzip2-devel

5. Install libjpeg and libjpeg- devel:

sudo yum -y install libjpeg libjpeg-devel

6. Install libpng and libpng-devel:

sudo yum -y install libpng libpng-devel

7. Install libmcrypt and libmcrypt-devel:

sudo yum -y install libmcrypt libmcrypt-devel

8. Install zlib and zlib-devel:

sudo yum -y install zlib zlib-devel

9. Install libzip and libzip-devel:

sudo yum -y install libzip libzip-devel

4. Install PHP-FPM

After confirming the installation environment and dependencies, you can start the installation of PHP-FPM.

1. Unzip the source code of PHP-FPM:

tar xzf php-7.4.12.tar.gz
cd php-7.4.12/

2 .Compile and configure:

./configure --prefix=/usr/local/php --with-fpm-user=www --with-fpm-group=www --with-gd -- enable-gd --with-jpeg --with-png --with-freetype --enable-bcmath --enable-fpm --enable-mbstring --enable-mysqlnd --with-zlib --with-zip -- with-mysqli --with-pdo-mysql --with-openssl

Please note that the above configure command will compile and configure PHP-FPM, and install library files, configuration files, etc. to /usr /local/php directory.

3. Install:

make && make install

4. Copy php.ini:

cp php.ini-production /usr/local /php/lib/php.ini

5. Modify the PHP-FPM configuration file:

cp /usr/local/php/etc/php-fpm.conf.default /usr/ local/php/etc/php-fpm.conf
vim /usr/local/php/etc/php-fpm.conf

Please modify php-fpm.conf according to the following configuration:

user = www
group = www
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
listen.backlog = -1
listen.owner = www
listen.group = www
listen.mode = 0666
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 8
pm.process_idle_timeout = 10s
pm.max_requests = 2048

The above configuration is a basic PHP-FPM configuration example, you can modify it according to actual needs.

6. Start PHP-FPM:

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

5. Test

After the installation is completed, Check whether the /usr/local/php directory exists and whether php-fpm is running. You can use the following command to test whether PHP-FPM has been installed correctly:

/usr/local/php/bin/php - v
/usr/local/php/sbin/php-fpm -v

The above commands are used to view the PHP-FPM version and status respectively.

6. Summary

This article explains the installation and configuration process of PHP-FPM. I hope it will be helpful to the majority of PHP engineers and operation and maintenance engineers to avoid some configuration and installation aspects. The problem. I wish everyone can successfully install and use PHP-FPM and better adapt to various application scenarios!

The above is the detailed content of How to compile and install PHP-FPM from source code. 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

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)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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)

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.

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 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 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 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 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.

How do you retrieve data from a database using PHP? How do you retrieve data from a database using PHP? Mar 20, 2025 pm 04:57 PM

Article discusses retrieving data from databases using PHP, covering steps, security measures, optimization techniques, and common errors with solutions.Character count: 159

What is the purpose of prepared statements in PHP? What is the purpose of prepared statements in PHP? Mar 20, 2025 pm 04:47 PM

Prepared statements in PHP enhance database security and efficiency by preventing SQL injection and improving query performance through compilation and reuse.Character count: 159

See all articles