How to install php-fpm on centos7

藏色散人
Release: 2020-07-24 09:48:51
Original
4587 people have browsed it

How to install "php-fpm" in centos7: first install "php-fpm" related components through yum; then modify the content in "default.conf" to support php; finally restart the nginx service.

How to install php-fpm on centos7

Recommended: "centos Getting Started Tutorial"

##CentOS7 uses yum to install Nginx php-fpm

Environment

[root@localhost html]# cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core) 
[root@localhost sbin]# /usr/sbin/nginx -v
nginx version: nginx/1.14.0
[root@localhost /]# php-fpm -v
PHP 5.4.16 (fpm-fcgi) (built: Apr 12 2018 19:03:25)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Copy after login

1. Install nginx

rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install -y nginx
systemctl start nginx
systemctl status nginx
systemctl stop nginx
systemctl enable nginx
Copy after login

Open the following address with a browser to access it It means the configuration is successful

http://192.168.0.61/
Copy after login

2.yum installs php-fpm related components

yum -y install php php-fpm php-gd php-mysql php-common php-pear php-mbstring php-mcrypt
systemctl status php-fpm
systemctl start php-fpm
systemctl enable php-fpm
Copy after login

3. Edit /etc/nginx/conf.d/default.conf and add the following content to support php

vim /etc/nginx/conf.d/default.conf

#
location ~ \.php$ {
    root           /usr/share/nginx/html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
}
Copy after login

After modifying the configuration, you need to restart the nginx service

4. Create the index.php file and test

vim /usr/share/nginx/html/index.php

<?php
    phpinfo();
?>
Copy after login

Open: http://192.168.0.61

The above is the detailed content of How to install php-fpm on centos7. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!