这篇文章主要介绍php5-fpm的安装方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
安装php5-fpm的方法:首先安装nginx,并建立nginx用户;然后修改nginx配置文件以支持php-fpm;接着通过“apt-get -y install”命令php5-fpm及php;最后修改php-fpm配置文件即可。
nginx+php5-fpm安装
一、基础环境
1、 cat /etc/debian_version 7.8 2、 uname -r3.2.0-4-amd64 3、ip(eth0)10.0.0.109
nginx版本
1.4.7
二、安装nginx
安装所需要的基础包
apt-get -y install libpcre3-dev libpcre3 libssl-dev zlib1g-dev make
建立nginx用户
1)groupadd nginx2) useradd nginx -g nginx -s /bin/false
下载nginx
axel -n 10 http: //nginx .org /download/nginx-1 .4.7. tar .gz
解压
tar zxvf nginx-1.4.7. tar .gz && cd nginx-1.4.7
编译三部曲
1). /configure --prefix= /opt/nginx --user=nginx --group=nginx --with-http_ssl_module2) make && make install
参数说明
--prefix= /opt/nginx 将安装路径指定在 /opt/nginx http_ssl_module https协议模块http_gzip_module 压缩的HTTP服务器的响应模块http_rewrite_module 重写模块--user=nginx nginx用户 --group=nginx nginx组
为了方便 弄个软链接
ln -s /opt/nginx/sbin/nginx /usr/local/sbin/nginx
【推荐:PHP视频教程】
修改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;> #}
启动nginx服务
nginx
查看端口和进程
1) netstat -tupnl| grep nginxtcp 0 0 10.0.0.109:80 0.0.0.0:* LISTEN 13852 /nginx : master2) ps -ef | grep nginxroot 13852 1 0 22:51 ? 00:00:00 nginx: master process nginxnginx 13853 13852 0 22:51 ? 00:00:00 nginx: worker processnginx 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:
停止nginx服务
nginx -s quit
重新加载配置
nginx -s reload
三、安装php5-fpm
安装php5-fpm及php
apt-get -y install php5-cliapt-get -y install php5-fpm
修改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-data33c33< listen = /run/shm/php5-fpm .sock---> listen = /var/run/php5-fpm .sock44,46c44,46< listen.owner = nginx< listen.group = nginx< listen.mode = 0660---> listen.owner = www-data> listen.group = www-data> ;listen.mode = 0660
重启php-fpm服务
/etc/init .d /php5-fpm restart
查看进程
ps -ef | grep phproot 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 <?phpphpinfo();?>;
五、nginx相关模块及参考文章
nginx相关模块
ngx_http_core_modulengx_http_access_modulengx_http_addition_modulengx_http_auth_basic_modulengx_http_auth_request_modulengx_http_autoindex_modulengx_http_browser_modulengx_http_charset_modulengx_http_dav_modulengx_http_empty_gif_modulengx_http_f4f_modulengx_http_fastcgi_modulengx_http_flv_modulengx_http_geo_modulengx_http_geoip_modulengx_http_gunzip_modulengx_http_gzip_modulengx_http_gzip_static_modulengx_http_headers_modulengx_http_hls_modulengx_http_image_filter_modulengx_http_index_modulengx_http_limit_conn_modulengx_http_limit_req_modulengx_http_log_modulengx_http_map_modulengx_http_memcached_modulengx_http_mp4_modulengx_http_perl_modulengx_http_proxy_modulengx_http_random_index_modulengx_http_realip_modulengx_http_referer_modulengx_http_rewrite_modulengx_http_scgi_modulengx_http_secure_link_modulengx_http_session_log_modulengx_http_spdy_modulengx_http_split_clients_modulengx_http_ssi_modulengx_http_ssl_modulengx_http_status_modulengx_http_stub_status_modulengx_http_sub_modulengx_http_upstream_modulengx_http_upstream_conf_modulengx_http_userid_modulengx_http_uwsgi_modulengx_http_xslt_module ngx_mail_core_modulengx_mail_auth_http_modulengx_mail_proxy_modulengx_mail_ssl_modulengx_mail_imap_modulengx_mail_pop3_modulengx_mail_smtp_module ngx_stream_core_modulengx_stream_access_modulengx_stream_limit_conn_modulengx_stream_proxy_modulengx_stream_ssl_modulengx_stream_upstream_module
以上是“php5-fpm的安装方法”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注编程网行业资讯频道!