search
HomeBackend DevelopmentPHP ProblemHow to install php-fpm on centos

How to install php-fpm on centos

Nov 16, 2020 am 09:44 AM
centosphp-fpm

How to install php-fpm on centos: first download and install php-fpm through the command "tar zvxf php-5.4.7.tar.gz"; then compile and install nginx; finally modify the nginx configuration file to support php- fpm is enough.

How to install php-fpm on centos

Recommended: "PHP Video Tutorial"

nginx itself cannot handle PHP, it is just a web server. After receiving the request, if it is a PHP request, it is sent to the PHP interpreter for processing and the result is returned to the client.

nginx usually sends the request to the fastcgi management process for processing. The fascgi management process selects the cgi sub-process processing result and returns it to nginx

This article uses php-fpm as an example to introduce how to make nginx support PHP

1. Compile and install php-fpm

What is PHP-FPM

PHP-FPM is a PHP FastCGI manager that is only used for PHP It can be downloaded at http://php-fpm.org/download.

PHP-FPM is actually a patch of the PHP source code, aiming to integrate FastCGI process management into the PHP package. It must be patched into your PHP source code, and it can be used after compiling and installing PHP.

The new version of PHP has integrated php-fpm. It is no longer a third-party package. It is recommended to use . PHP-FPM provides a better PHP process management method, which can effectively control memory and processes, and can smoothly reload PHP configuration. It has more advantages than spawn-fcgi, so it is officially included in PHP. PHP-FPM can be turned on by passing the –enable-fpm parameter in ./configure.

New version of php-fpm installation (recommended installation method)

wget http://cn2.php.net/distributions/php-5.4.7.tar.gz

tar zvxf php-5.4.7.tar.gz

cd php-5.4.7

./configure --prefix=/usr/local/php -- enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --disable-pdo --with-curl --disable-debug --enable-pic --disable-rpath -- enable-inline-optimization --with-bz2 --with-xml --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-xslt --enable-memcache --enable-zip --with-pcre-regex --with-mysql

make all install

Old version manual patch php -fpm install

wget http://cn2.php.net/get/php-5.2.17.tar.gz
wget http://php-fpm.org/downloads/ php-5.2.17-fpm-0.5.14.diff.gz

tar zvxf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.14. diff.gz | patch -d php-5.2.17 -p1
cd php-5.2.17
./configure --prefix=/usr/local/php --enable-fastcgi --enable-fpm - -with-mcrypt --with-zlib --enable-mbstring --disable-pdo --with-curl --disable-debug --enable-pic --disable-rpath --enable-inline-optimization --with- bz2 --with-xml --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-xslt --enable- memcache --enable-zip --with-pcre-regex --with-mysql

make all install

Both of the above two methods can install php-fpm. After installation, the content will be placed in / In the usr/local/php directory

How to install php-fpm on centos

cd /usr/local/php

cp etc/php-fpm.conf.default etc/php-fpm .conf

Modify

vi etc/php-fpm.conf.default etc/php-fpm.conf

user = www-data
group = www- data

2. Compile and install nginx

Then follow http://www.nginx.cn/install to install nginx

3. Modify the nginx configuration file to support php-fpm

After the nginx installation is completed, modify the nginx configuration file to,nginx.conf

Add the following configuration to the server section, pay attention to the red content configuration, otherwise the No input file specified. error will occur

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#location ~ How to install php-fpm on centos.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

4. Create test php file

Create php file

Create the index.php file under /usr/local/nginx/html and enter the following content

echo phpinfo(); ?>

5. Start the service

Start php-fpm and nginx

/usr/local/php/sbin/php-fpm (manual patch startup method/usr/local/php/sbin/php-fpm start )

sudo /usr/local/nginx/nginx

6. Browser access

Visit http://your server ip/index.php, all can be seen To the php information.

How to install php-fpm on centos

##7. cp /root/php-5.3.21/php.ini-development /opt/php/lib

Put into the PHP configuration file

Errors you may encounter when installing php-fpm:

1. Error when phpconfigure

configure: error: XML configuration could not be found

apt-get install libxml2 libxml2-dev (under ubuntu)
yum -y install libxml2 libxml2-devel (under centos)

2. Please reinstall the BZip2 distribution

wget http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz
tar -zxvf bzip2-1.0.5.tar.gz
cd bzip2-1.0. 5
make
make install
3.php has a line in the configuration file --with-mysql=/usr. When installing, it prompts:
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore.

This is because the mysql header is not installed when installing mysql. file, or the path is incorrectly specified, and php cannot find the error message caused by the mysql header file.
Solution.
(1.) Check whether mysql header is installed on your system
find / -name mysql.h
If so. Please specify --with-mysql=/ and your normal path.
if there is not. Please see the next step.
(2.)redhat installation
rpm -ivh MySQL-devel-4.1.12-1.i386.rpm
(3.)ubuntu installation
apt-get install libmysqlclient15-dev
(4.) In the last step, add --with-mysql=/usr to the php configuration option!
4.No input file specified.

location ~ How to install php-fpm on centos.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

5. If the library is missing when php configure, you can install the library first (under ubuntu)

sudo apt-get install make bison flex gcc patch autoconf subversion locate
sudo apt-get install libxml2-dev libbz2-dev libpcre3-dev libssl-dev zlib1g-dev libmcrypt-dev libmhash-dev libmhash2 libcurl4-openssl-dev libpq-dev libpq5 libsyck0- de

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

Video Face Swap

Video Face Swap

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

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software