Table of Contents
1. Delete the old version of php
2. Install php
3. Configure using php-fpm
nginx and fastcgi There are two communication methods, one is TCP method, and the other is unix socket method
1. TCP configuration method
2. Unix socket configuration method
Use a file (usually .sock) as the unique identifier (descriptor) of the socket. Two processes that need to communicate can establish a channel for communication by referencing the same socket descriptor file. .
Home Backend Development PHP7 How to install php-fpm in php7

How to install php-fpm in php7

Dec 29, 2021 am 09:46 AM
php-fpm php7

How to install and configure php-fpm in php7: 1. Install the PHP7 suite and plug-ins; 2. Create a socket descriptor file; 3. Modify the php-fpm configuration file; 4. Restart php-fpm.

How to install php-fpm in php7

The operating environment of this article: centos7 system, PHP version 7.1, Dell G3 computer.

How to install php-fpm in php7?

Install php7.1 and php-fpm (centos7, nginx)

1. Delete the old version of php

#yum remove php-common

2. Install php

Details: https://wiki.centos.org/zh-tw/HowTos/php7?highlight=(php7)

First, install the software library (it is an official software library that needs to be started).
# yum -y install centos-release-scl.noarch
Install the PHP 7 suite and its plug-ins.
\ # yum -y install rh-php70 rh-php70-php rh-php70-php-fpm

3. Configure using php-fpm

nginx and fastcgi There are two communication methods, one is TCP method, and the other is unix socket method
  • TCP uses TCP port to connect 127.0.0.1:9000
  • Socket uses unix domain Socket connection socket
1. TCP configuration method
  • Edit /etc/nginx/conf.d/your site configuration file. Modify the fastcgi_pass parameter to 127.0.0.1:9000
  • Edit the php-fpm configuration file /etc/opt/rh/rh-php71/php-fpm.d/www.conf
  • Set the values ​​of user and group to nginx
    user = nginx
    group = nginx
  • listen value setting is 127.0.0.1:9000, which is the same as the value of the fastcgi_pass parameter in the site configuration file
  • After completion, we must change the selinux database and add port 9000 to serve httpd Valid connection.

semanage port -a -t http_port_t -p tcp 9000

  • Restart php-fpm, restart nginx
2. Unix socket configuration method
Use a file (usually .sock) as the unique identifier (descriptor) of the socket. Two processes that need to communicate can establish a channel for communication by referencing the same socket descriptor file. .
  • Create socket descriptor file
sudo touch /var/run/php7.1-fpm.sock
sudo chown nginx:nginx /var/run/php7.1-fpm.sock
sudo chmod 666 /var/run/php7.1-fpm.sock
Copy after login
  • Modify the php-fpm configuration file
  • The values ​​of user and group are set to nginx
    user = nginx
    group = nginx
  • The value of listen is set to /var/run/php7. 1-fpm.sock, which is the same as the value of the fastcgi_pass parameter in the site configuration file
  • Remove the semicolon in front of listen.owner, listen.group, and listen.mode to make php-fpm use unix socket and change The values ​​of listen.owner and listen.group are set to nginx
    listen.owner = nginx
    listen.group = nginx
  • Modify the nginx site configuration file. Edit /etc/nginx/conf.d/your site configuration file. Change the fastcgi_pass parameter to /var/run/php7.1-fpm.sock
  • Restart nginx and php-fpm services (it is best to restart php-fpm first and then restart nginx) [Recommended learning: PHP Video tutorial

The above is the detailed content of How to install php-fpm in php7. 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)

How to use php-fpm for high-performance tuning How to use php-fpm for high-performance tuning Jul 08, 2023 am 11:30 AM

How to use php-fpm for high-performance tuning PHP is a very popular server-side scripting language that is widely used to develop web applications and dynamic websites. However, as traffic increases, the performance of your PHP application may suffer. In order to solve this problem, we can use php-fpm (FastCGIProcessManager) for high-performance tuning. This article will introduce how to use php-fpm to improve the performance of PHP applications and provide code examples. one,

How to use PHP-FPM optimization to improve the performance of PrestaShop applications How to use PHP-FPM optimization to improve the performance of PrestaShop applications Oct 05, 2023 pm 12:33 PM

How to use PHP-FPM optimization to improve the performance of PrestaShop applications. With the rapid development of the e-commerce industry, PrestaShop has become the e-commerce platform chosen by many merchants. However, as the size of the store increases and the number of visits increases, the PrestaShop application may encounter performance bottlenecks. In order to improve the performance of the PrestaShop application, a common method is to use PHP-FPM to optimize and improve the application's processing capabilities. PHP-FPM (FastCGI

How to improve the performance of your WooCommerce application using PHP-FPM optimization How to improve the performance of your WooCommerce application using PHP-FPM optimization Oct 05, 2023 am 08:24 AM

How to Improve the Performance of WooCommerce Applications Using PHP-FPM Optimization Overview WooCommerce is a very popular e-commerce plugin for creating and managing online stores on WordPress websites. However, as your store grows and traffic increases, WooCommerce apps can become slow and unstable. To solve this problem, we can use PHP-FPM to optimize and improve the performance of WooCommerce applications. What is PHP-FP

Use php-fpm connection pool to improve database access performance Use php-fpm connection pool to improve database access performance Jul 07, 2023 am 09:24 AM

Overview of using php-fpm connection pool to improve database access performance: In web development, database access is one of the most frequent and time-consuming operations. The traditional method is to create a new database connection for each database operation and then close the connection after use. This method will cause frequent establishment and closing of database connections, increasing system overhead. In order to solve this problem, you can use php-fpm connection pool technology to improve database access performance. Principle of connection pool: Connection pool is a caching technology that combines a certain number of databases

How to use PHP-FPM optimization to improve the performance of Phalcon applications How to use PHP-FPM optimization to improve the performance of Phalcon applications Oct 05, 2023 pm 01:54 PM

How to use PHP-FPM to optimize and improve the performance of Phalcon applications. Introduction: Phalcon is a high-performance PHP framework. Combining with PHP-FPM can further improve the performance of applications. This article will introduce how to use PHP-FPM to optimize the performance of Phalcon applications and provide specific code examples. 1. What is PHP-FPMPHP-FPM (PHPFastCGIProcessManager) is a PHP process independent of the web server

Detailed explanation of php-fpm tuning method Detailed explanation of php-fpm tuning method Jul 08, 2023 pm 04:31 PM

PHP-FPM is a commonly used PHP process manager used to provide better PHP performance and stability. However, in a high-load environment, the default configuration of PHP-FPM may not meet the needs, so we need to tune it. This article will introduce the tuning method of PHP-FPM in detail and give some code examples. 1. Increase the number of processes. By default, PHP-FPM only starts a small number of processes to handle requests. In a high-load environment, we can improve the concurrency of PHP-FPM by increasing the number of processes

What should I do if the plug-in is installed in php7.0 but it still shows that it is not installed? What should I do if the plug-in is installed in php7.0 but it still shows that it is not installed? Apr 02, 2024 pm 07:39 PM

To resolve the plugin not showing installed issue in PHP 7.0: Check the plugin configuration and enable the plugin. Restart PHP to apply configuration changes. Check the plugin file permissions to make sure they are correct. Install missing dependencies to ensure the plugin functions properly. If all other steps fail, rebuild PHP. Other possible causes include incompatible plugin versions, loading the wrong version, or PHP configuration issues.

PHP-FPM performance improvement strategies and practice guide PHP-FPM performance improvement strategies and practice guide Oct 05, 2023 pm 03:55 PM

Introduction to PHP-FPM Performance Improvement Strategies and Practice Guide: With the rapid development of the Internet and the increasing number of website visits, it is particularly important to improve the performance of PHP applications. PHPFastCGIProcessManager (PHP-FPM) is a commonly used PHP process manager that can improve the performance of PHP applications through a series of strategies and practices. This article will introduce some PHP-FPM performance improvement strategies, combined with specific code examples, to help readers better understand

See all articles