Home Backend Development PHP Problem How to install php-fpm on centos

How to install php-fpm on centos

Nov 16, 2020 am 09:44 AM
centos php-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 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)

What are the backup methods for GitLab on CentOS What are the backup methods for GitLab on CentOS Apr 14, 2025 pm 05:33 PM

Backup and Recovery Policy of GitLab under CentOS System In order to ensure data security and recoverability, GitLab on CentOS provides a variety of backup methods. This article will introduce several common backup methods, configuration parameters and recovery processes in detail to help you establish a complete GitLab backup and recovery strategy. 1. Manual backup Use the gitlab-rakegitlab:backup:create command to execute manual backup. This command backs up key information such as GitLab repository, database, users, user groups, keys, and permissions. The default backup file is stored in the /var/opt/gitlab/backups directory. You can modify /etc/gitlab

How to optimize CentOS HDFS configuration How to optimize CentOS HDFS configuration Apr 14, 2025 pm 07:15 PM

Improve HDFS performance on CentOS: A comprehensive optimization guide to optimize HDFS (Hadoop distributed file system) on CentOS requires comprehensive consideration of hardware, system configuration and network settings. This article provides a series of optimization strategies to help you improve HDFS performance. 1. Hardware upgrade and selection resource expansion: Increase the CPU, memory and storage capacity of the server as much as possible. High-performance hardware: adopts high-performance network cards and switches to improve network throughput. 2. System configuration fine-tuning kernel parameter adjustment: Modify /etc/sysctl.conf file to optimize kernel parameters such as TCP connection number, file handle number and memory management. For example, adjust TCP connection status and buffer size

Centos shutdown command line Centos shutdown command line Apr 14, 2025 pm 09:12 PM

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

What are the common misunderstandings in CentOS HDFS configuration? What are the common misunderstandings in CentOS HDFS configuration? Apr 14, 2025 pm 07:12 PM

Common problems and solutions for Hadoop Distributed File System (HDFS) configuration under CentOS When building a HadoopHDFS cluster on CentOS, some common misconfigurations may lead to performance degradation, data loss and even the cluster cannot start. This article summarizes these common problems and their solutions to help you avoid these pitfalls and ensure the stability and efficient operation of your HDFS cluster. Rack-aware configuration error: Problem: Rack-aware information is not configured correctly, resulting in uneven distribution of data block replicas and increasing network load. Solution: Double check the rack-aware configuration in the hdfs-site.xml file and use hdfsdfsadmin-printTopo

Centos stops maintenance 2024 Centos stops maintenance 2024 Apr 14, 2025 pm 08:39 PM

CentOS will be shut down in 2024 because its upstream distribution, RHEL 8, has been shut down. This shutdown will affect the CentOS 8 system, preventing it from continuing to receive updates. Users should plan for migration, and recommended options include CentOS Stream, AlmaLinux, and Rocky Linux to keep the system safe and stable.

How to install mysql in centos7 How to install mysql in centos7 Apr 14, 2025 pm 08:30 PM

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

What steps are required to configure CentOS in HDFS What steps are required to configure CentOS in HDFS Apr 14, 2025 pm 06:42 PM

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

How to check CentOS HDFS configuration How to check CentOS HDFS configuration Apr 14, 2025 pm 07:21 PM

Complete Guide to Checking HDFS Configuration in CentOS Systems This article will guide you how to effectively check the configuration and running status of HDFS on CentOS systems. The following steps will help you fully understand the setup and operation of HDFS. Verify Hadoop environment variable: First, make sure the Hadoop environment variable is set correctly. In the terminal, execute the following command to verify that Hadoop is installed and configured correctly: hadoopversion Check HDFS configuration file: The core configuration file of HDFS is located in the /etc/hadoop/conf/ directory, where core-site.xml and hdfs-site.xml are crucial. use

See all articles