How to install php-fpm on centos

藏色散人
Release: 2023-03-07 15:54:02
Original
3125 people have browsed it

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!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template