How to install php-fpm on centos
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.
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
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.
Errors you may encounter when installing php-fpm:
1. Error when phpconfigureconfigure: error: XML configuration could not be foundapt-get install libxml2 libxml2-dev (under ubuntu)
yum -y install libxml2 libxml2-devel (under centos)
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!

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

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

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

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

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

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.

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

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

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

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
