首頁 後端開發 PHP問題 php5-fpm怎麼安裝

php5-fpm怎麼安裝

Mar 19, 2021 am 09:37 AM

安裝php5-fpm的方法:先安裝nginx,並建立nginx使用者;然後修改nginx設定檔以支援php-fpm;接著透過「apt-get -y install」指令php5-fpm及php;最後修改php-fpm設定檔即可。

php5-fpm怎麼安裝

本文操作環境:debian7.8系統、PHP5版,DELL G3電腦

nginx php5-fpm安裝

一、基礎環境

1、 cat  /etc/debian_version 
7.8
 
2、 uname  -r
3.2.0-4-amd64
 
3、ip(eth0)
10.0.0.109
登入後複製

 

4、nginx版本

1.4.7
登入後複製

 

二、安裝nginx

1.安裝所需的基礎套件

apt-get -y  install  libpcre3-dev libpcre3 libssl-dev zlib1g-dev  make
登入後複製

 

2、建立nginx用戶

1)groupadd nginx
2) useradd  nginx -g nginx -s  /bin/false
登入後複製

 

3、下載nginx

axel -n 10 http: //nginx .org /download/nginx-1 .4.7. tar .gz
登入後複製

4、解壓縮

tar  zxvf nginx-1.4.7. tar .gz &&  cd  nginx-1.4.7
登入後複製

 

5、編譯三部曲

1). /configure  --prefix= /opt/nginx  --user=nginx --group=nginx --with-http_ssl_module
2) make  &&  make  install
登入後複製

 

6、參數說明

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

 

7、為了方便弄個軟連結

ln  -s  /opt/nginx/sbin/nginx  /usr/local/sbin/nginx
登入後複製

 【推薦:PHP影片教學

#8、修改nginx設定檔以支持php-fpm

1)先備份下

cp  /opt/nginx/conf/nginx .conf  /opt/nginx/conf/nginx .conf.bak
登入後複製

2)修改下列內容

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;
>          #}
登入後複製

9、啟動nginx服務

nginx
登入後複製

 

10、檢視連接埠和進程

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
登入後複製

 

PS:

1、停止nginx服務

nginx -s quit
登入後複製

2、重新載入設定

nginx -s reload
登入後複製

 

三、安裝php5-fpm

1、安裝php5-fpm及php

apt-get -y  install  php5-cli
apt-get -y  install  php5-fpm
登入後複製

 

2、修改php-fpm設定檔

1)先備份下

cp  /etc/php5/fpm/pool .d /www .conf  /etc/php5/fpm/pool .d /www .conf.bak
登入後複製

2)修改下列內容

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
登入後複製

 

3、重新啟動php-fpm服務

/etc/init .d /php5-fpm  restart
登入後複製

 

4、查看進程

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
登入後複製

 

四、寫個php檔案測試

cat  /opt/nginx/html/info .php 
<?php
phpinfo();
?>;
登入後複製

 

五、nginx相關模組及參考文章

1、nginx相關模組

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
登入後複製

 

2、參考文章

http: //nginx .org /en/docs

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

以上是php5-fpm怎麼安裝的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1655
14
CakePHP 教程
1413
52
Laravel 教程
1306
25
PHP教程
1252
29
C# 教程
1226
24