How to compile and install PHP-FPM from source code
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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

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.

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.

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.

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

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

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

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