Home Backend Development PHP Problem How to install php5-fpm

How to install php5-fpm

Mar 19, 2021 am 09:37 AM

How to install php5-fpm: First install nginx and create an nginx user; then modify the nginx configuration file to support php-fpm; then use "apt-get -y install" command php5-fpm and php; Finally modify the php-fpm configuration file.

How to install php5-fpm

The operating environment of this article: debian7.8 system, PHP5 version, DELL G3 computer

nginx php5-fpm installation

1. Basic environment

1、 cat  /etc/debian_version 
7.8
 
2、 uname  -r
3.2.0-4-amd64
 
3、ip(eth0)
10.0.0.109
Copy after login

4. nginx version

1.4.7
Copy after login

2. Install nginx

1. Install the required basic packages

apt-get -y  install  libpcre3-dev libpcre3 libssl-dev zlib1g-dev  make
Copy after login

2. Create nginx user

1)groupadd nginx
2) useradd  nginx -g nginx -s  /bin/false
Copy after login

3. Download nginx

axel -n 10 http: //nginx .org /download/nginx-1 .4.7. tar .gz
Copy after login

4. Unzip

tar  zxvf nginx-1.4.7. tar .gz &&  cd  nginx-1.4.7
Copy after login

5. Compile the trilogy

1). /configure  --prefix= /opt/nginx  --user=nginx --group=nginx --with-http_ssl_module
2) make  &&  make  install
Copy after login

6. Parameter description

--prefix= /opt/nginx     将安装路径指定在 /opt/nginx 
http_ssl_module         https协议模块
http_gzip_module        压缩的HTTP服务器的响应模块
http_rewrite_module     重写模块
--user=nginx            nginx用户 
--group=nginx           nginx组
Copy after login

7. For convenience, make a soft link

ln  -s  /opt/nginx/sbin/nginx  /usr/local/sbin/nginx
Copy after login

[Recommended: PHP video tutorial]

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

1) Back up first

cp  /opt/nginx/conf/nginx .conf  /opt/nginx/conf/nginx .conf.bak
Copy after login

2) Modify the following content

2c2
< user nginx;
---
>  #user  nobody;
36,39c36,38
<         listen       10.0.0.109:80;
<         server_name  10.0.0.109;
<         access_log  /opt/nginx/logs/10 .0.0.109.access.log;
<         error_log  /opt/nginx/logs/10 .0.0.109.error.log;
---
>         listen       80;
>         server_name  localhost;
> 
66,72c65,71
<         location ~ \.php$ {
<             root           html;
<             fastcgi_pass   unix: /run/shm/php5-fpm .sock;
<             fastcgi_index  index.php;
<             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
<             include        fastcgi_params;
<         }
---
>          #location ~ \.php$ {
>          #    root           html;
>          #    fastcgi_pass   127.0.0.1:9000;
>          #    fastcgi_index  index.php;
>          #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
>          #    include        fastcgi_params;
>          #}
Copy after login

9. Start nginx service

nginx
Copy after login

10. Check ports and processes

1) netstat  -tupnl| grep  nginx
tcp        0      0 10.0.0.109:80           0.0.0.0:*               LISTEN      13852 /nginx : master
2) ps  -ef | grep  nginx
root     13852     1  0 22:51 ?        00:00:00 nginx: master process nginx
nginx    13853 13852  0 22:51 ?        00:00:00 nginx: worker process
nginx    13907 13906  0 22:52 ?        00:00:00 php-fpm: pool www                                         
nginx    13908 13906  0 22:52 ?        00:00:00 php-fpm: pool www
Copy after login

PS:

1. Stop nginx service

nginx -s quit
Copy after login

2. Reload configuration

nginx -s reload
Copy after login

3. Install php5-fpm

1. Install php5-fpm and php

apt-get -y  install  php5-cli
apt-get -y  install  php5-fpm
Copy after login

2. Modify the php-fpm configuration file

1) Back up first

cp  /etc/php5/fpm/pool .d /www .conf  /etc/php5/fpm/pool .d /www .conf.bak
Copy after login

2) Modify the following content

diff  /etc/php5/fpm/pool .d /www .conf  /etc/php5/fpm/pool .d /www .conf.bak 
22,23c22,23
< user = nginx
< group = nginx
---
> user = www-data
> group = www-data
33c33
< listen =  /run/shm/php5-fpm .sock
---
> listen =  /var/run/php5-fpm .sock
44,46c44,46
< listen.owner = nginx
< listen.group = nginx
< listen.mode = 0660
---
> listen.owner = www-data
> listen.group = www-data
> ;listen.mode = 0660
Copy after login

3. Restart the php-fpm service

/etc/init .d /php5-fpm  restart
Copy after login

4. Check the process

ps  -ef | grep  php
root     13906     1  0 22:52 ?        00:00:00 php-fpm: master process ( /etc/php5/fpm/php-fpm .conf)      
nginx    13907 13906  0 22:52 ?        00:00:00 php-fpm: pool www                                         
nginx    13908 13906  0 22:52 ?        00:00:00 php-fpm: pool www
Copy after login

4. Write a php file to test

cat  /opt/nginx/html/info .php 
<?php
phpinfo();
?>;
Copy after login

5. nginx related modules and reference articles

1. nginx related modules

ngx_http_core_module
ngx_http_access_module
ngx_http_addition_module
ngx_http_auth_basic_module
ngx_http_auth_request_module
ngx_http_autoindex_module
ngx_http_browser_module
ngx_http_charset_module
ngx_http_dav_module
ngx_http_empty_gif_module
ngx_http_f4f_module
ngx_http_fastcgi_module
ngx_http_flv_module
ngx_http_geo_module
ngx_http_geoip_module
ngx_http_gunzip_module
ngx_http_gzip_module
ngx_http_gzip_static_module
ngx_http_headers_module
ngx_http_hls_module
ngx_http_image_filter_module
ngx_http_index_module
ngx_http_limit_conn_module
ngx_http_limit_req_module
ngx_http_log_module
ngx_http_map_module
ngx_http_memcached_module
ngx_http_mp4_module
ngx_http_perl_module
ngx_http_proxy_module
ngx_http_random_index_module
ngx_http_realip_module
ngx_http_referer_module
ngx_http_rewrite_module
ngx_http_scgi_module
ngx_http_secure_link_module
ngx_http_session_log_module
ngx_http_spdy_module
ngx_http_split_clients_module
ngx_http_ssi_module
ngx_http_ssl_module
ngx_http_status_module
ngx_http_stub_status_module
ngx_http_sub_module
ngx_http_upstream_module
ngx_http_upstream_conf_module
ngx_http_userid_module
ngx_http_uwsgi_module
ngx_http_xslt_module
 
ngx_mail_core_module
ngx_mail_auth_http_module
ngx_mail_proxy_module
ngx_mail_ssl_module
ngx_mail_imap_module
ngx_mail_pop3_module
ngx_mail_smtp_module
 
ngx_stream_core_module
ngx_stream_access_module
ngx_stream_limit_conn_module
ngx_stream_proxy_module
ngx_stream_ssl_module
ngx_stream_upstream_module
Copy after login

2. Reference article

http: //nginx .org /en/docs

http: //tengine .taobao.org /nginx_docs/cn/docs/http/ngx_http_core_module .html

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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 best practices for deduplication of PHP arrays What are the best practices for deduplication of PHP arrays Mar 03, 2025 pm 04:41 PM

This article explores efficient PHP array deduplication. It compares built-in functions like array_unique() with custom hashmap approaches, highlighting performance trade-offs based on array size and data type. The optimal method depends on profili

Does PHP array deduplication need to be considered for performance losses? Does PHP array deduplication need to be considered for performance losses? Mar 03, 2025 pm 04:47 PM

This article analyzes PHP array deduplication, highlighting performance bottlenecks of naive approaches (O(n²)). It explores efficient alternatives using array_unique() with custom functions, SplObjectStorage, and HashSet implementations, achieving

Can PHP array deduplication take advantage of key name uniqueness? Can PHP array deduplication take advantage of key name uniqueness? Mar 03, 2025 pm 04:51 PM

This article explores PHP array deduplication using key uniqueness. While not a direct duplicate removal method, leveraging key uniqueness allows for creating a new array with unique values by mapping values to keys, overwriting duplicates. This ap

How to Implement message queues (RabbitMQ, Redis) in PHP? How to Implement message queues (RabbitMQ, Redis) in PHP? Mar 10, 2025 pm 06:15 PM

This article details implementing message queues in PHP using RabbitMQ and Redis. It compares their architectures (AMQP vs. in-memory), features, and reliability mechanisms (confirmations, transactions, persistence). Best practices for design, error

What Are the Latest PHP Coding Standards and Best Practices? What Are the Latest PHP Coding Standards and Best Practices? Mar 10, 2025 pm 06:16 PM

This article examines current PHP coding standards and best practices, focusing on PSR recommendations (PSR-1, PSR-2, PSR-4, PSR-12). It emphasizes improving code readability and maintainability through consistent styling, meaningful naming, and eff

What are the optimization techniques for deduplication of PHP arrays What are the optimization techniques for deduplication of PHP arrays Mar 03, 2025 pm 04:50 PM

This article explores optimizing PHP array deduplication for large datasets. It examines techniques like array_unique(), array_flip(), SplObjectStorage, and pre-sorting, comparing their efficiency. For massive datasets, it suggests chunking, datab

How Do I Work with PHP Extensions and PECL? How Do I Work with PHP Extensions and PECL? Mar 10, 2025 pm 06:12 PM

This article details installing and troubleshooting PHP extensions, focusing on PECL. It covers installation steps (finding, downloading/compiling, enabling, restarting the server), troubleshooting techniques (checking logs, verifying installation,

How to Use Reflection to Analyze and Manipulate PHP Code? How to Use Reflection to Analyze and Manipulate PHP Code? Mar 10, 2025 pm 06:12 PM

This article explains PHP's Reflection API, enabling runtime inspection and manipulation of classes, methods, and properties. It details common use cases (documentation generation, ORMs, dependency injection) and cautions against performance overhea

See all articles