`
sillycat
  • 浏览: 2551030 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

PHP(6)PHP with fpm and NGINX

    博客分类:
  • PHP
 
阅读更多
PHP(6)PHP with fpm and NGINX

1. Set Up latest PHP with Nginx
If get some problem with libtool to build some library. We should use
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool

Install the nginx, place the pcre installation package there, you may need that.

Install the PHP with factCGI and work with nginx
http://sillycat.iteye.com/blog/2078154
http://sillycat.iteye.com/blog/2149513

PHP-FPM VS FastCGI
mod_php, it is a build-in module under apache. Apache HTTP server can support PHP.
FastCGI, interface between PHP and HTTP server. mod_fastcgi is a module under apache support FastCGI protocol. We can separate the PHP and Web Server.
PHP-FPM powerful, similar to span-cgi, support remote FastCGI. (FastCGI Process Manager)

Download the latest package
> wget http://ar2.php.net/distributions/php-5.6.10.tar.gz

Unzip that and prepare the tools we need.
> ./configure --prefix=/home/carl/tool/php-5.6.10 --with-openssl --with-iconv-dir=/usr/lib --with-curl=/opt/local/include/curl --with-mysql --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-mcrypt --with-zlib --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-pdo-mysql --with-mysqli --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm

Error Message:
configure: error: Cannot find OpenSSL's libraries

Solution:
http://mac-dev-env.patrickbougie.com/openssl/
> wget http://www.openssl.org/source/openssl-1.0.2c.tar.gz
Unzip and try to install that
> ./configure darwin64-x86_64-cc --prefix=/Users/carl/tool/openssl-1.0.2c
make and install them

> ./configure --prefix=/Users/carl/tool/php-5.6.10 --with-openssl --with-iconv-dir=/usr/lib --with-curl=/opt/local/include/curl --with-mysql --enable-fpm --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-mysqli

Make & Install that, php is adding to the path.
> php --version
PHP 5.6.10 (cli) (built: Jun 29 2015 17:35:04)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

Command to restart the nginx
> sudo sbin/nginx -s reload

Check configuration
> sudo sbin/php-fpm -t

Command to restart the php-fpm
> sudo sbin/php-fpm

Check the Permission
> sudo chown -R root:nobody /opt/nginx/html/
> sudo chmod g+w  /opt/nginx/htm

Change the configuration on php-fpm, the configuration file is
/opt/php/etc/php-fpm.conf

pid = run/php-fpm.pid
error_log = log/php-fpm.log
user = nobody
group = nobody
;listen = 127.0.0.1:9000
listen = var/run/php5-fpm.sock

Another configuration file
/opt/php/etc/php.ini

Error Message:
sudo sbin/nginx
nginx: [warn] 1024 worker_connections exceed open file resource limit: 256

Solution:
Check the Limit
> ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 709
virtual memory          (kbytes, -v) unlimited

Change the limit
> ulimit -n 1024

Then we can start the php-fpm
>sudo sbin/php-fpm

Make sure they are running
> ps -ef | grep fpm
    0 98821     1   0 Tue11AM ??         0:01.34 sbin/php-fpm
   -2 98822 98821   0 Tue11AM ??         0:00.00 sbin/php-fpm
   -2 98823 98821   0 Tue11AM ??         0:00.00 sbin/php-fpm
  501  2991  5692   0  2:37PM ttys006    0:00.01 grep fpm

Configuration on NGINX, the configuration file will be  /opt/nginx/conf/nginx.conf
        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;
            # with php5-fpm
            fastcgi_keep_conn on;
            try_files $uri =404;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_hide_header X-Powered-By;
            # fastcgi_pass 127.0.0.1:9000;
            fastcgi_pass unix:/opt/php/var/run/php5-fpm.sock;
        }

Place a very simple and hello world page  /opt/nginx/html/info.php
> cat info.php
<?php
phpinfo();
?>

Visit that page with URL
http://localhost/info.php

2. Recall PHP Knowledge
todo...
3. MySQLi
todo...

References:
http://sillycat.iteye.com/blog/2194084
http://sillycat.iteye.com/blog/2066063
http://sillycat.iteye.com/blog/1543227
http://sillycat.iteye.com/blog/769110
http://sillycat.iteye.com/blog/2149513
http://sillycat.iteye.com/blog/2078154

build PHP with fastcgi
https://www.howtoforge.com/how-to-build-php-5.6-fpm-fastcgi-with-zend-opcache-and-apcu-for-ispconfig-3-on-debian-7-wheezy
https://www.howtoforge.com/installing-nginx-with-php5-and-php-fpm-and-mysql-support-lemp-on-debian-wheezy
https://www.zybuluo.com/phper/note/50231
https://www.zybuluo.com/phper/note/50231

PHP-FPM
http://php-fpm.org/
分享到:
评论

相关推荐

    源码安装nginx+php-fpm+http push测试通过

    4. **编译安装PHP**:配置`PHP`的编译选项,包括`--with-php-fpm`以启用FastCGI模式,同时添加`--with-openssl`和`--with-zlib`。完成编译后,同样执行`make`和`make install`。 5. **配置Nginx**:编辑`nginx.conf...

    Nginx + PHP-FPM + APC=绝妙的组合

    【Nginx + PHP-FPM + APC 绝妙组合详解】 在互联网服务领域,Nginx、PHP-FPM(PHP FastCGI Process Manager)和 Alternative PHP Cache (APC) 的结合已经成为一种高效的Web服务器配置模式,尤其适用于高流量网站。...

    nginx php 安装与配置

    3. 调整Nginx和PHP-FPM的配置参数以优化性能。 通过以上步骤,你就可以搭建起一个运行PHP应用的Nginx服务器。然而,实际生产环境中,还需要考虑更多的因素,如日志管理、性能监控、安全策略等。在不断学习和实践中...

    安装配置php-fpm来搭建Nginx+PHP的生产环境

    搭建一个高效的Web服务器环境,尤其是对于处理PHP应用来说,Nginx与PHP-FPM的组合是常见的选择。本文将详细讲解如何安装配置php-fpm,以及如何与Nginx配合,构建一个生产级别的PHP环境。 首先,理解php-fpm的核心...

    PHP7.2+NGINX Linux环境搭建与脚本

    - 配置编译选项,包括Nginx模块支持:`./configure --prefix=/usr/local/php --with-config-file-path=/etc/php --with-config-file-scan-dir=/etc/php/conf.d --enable-fpm --with-fpm-user=nginx --with-fpm-...

    fpm模式安装php-5.4.40及xcache 1

    libxml-dir --enable-xml --enable-sockets --with-mcrypt --with-bz2 --with-config-file-path=/etc/php/php.ini --with-config-file-scan-dir=/etc/php.d/ --enable-fpm ``` 完成配置后,进行编译、测试和安装: ...

    详解Linux下安装php环境并且配置Nginx支持php-fpm模块

    在Linux环境下搭建PHP开发环境并配置Nginx支持PHP-FPM模块是Web开发者常见的任务之一。本文将详细介绍如何在CentOS 7.2上完成这个过程。 首先,你需要访问PHP官方网站(http://php.net/)下载最新版本的PHP源码包,...

    nginx安装包+php安装包+补丁+代码

    2. **配置**:执行`./configure`命令,选择需要的扩展和配置选项,如`--with-nginx`表示与Nginx集成。 3. **编译与安装**:同Nginx一样,使用`make`和`make install`进行编译和安装。 4. **PHP-FPM**:对于与Nginx...

    Installing_Nginx_With_PHP5_And_MySQL_Support_On_Debian_Squeeze.rar

    标题 "Installing Nginx With PHP5 And MySQL Support On Debian Squeeze" 涉及到的是在Debian Squeeze操作系统上安装Nginx web服务器、PHP5脚本语言支持以及MySQL数据库的过程。这是一个基础的LEMP(Linux、Nginx、...

    nginx及php安裝所需安裝包

    6. **启动PHP-FPM**:启动PHP-FPM服务,使其能够处理来自Nginx的请求。 7. **配置Nginx以与PHP配合**:在Nginx的配置文件中,添加处理PHP请求的location块,比如: ``` location ~ \.php$ { fastcgi_pass ...

    nginx php配置

    ### Nginx PHP配置知识点...- 性能调优方面,可根据服务器硬件和负载情况调整 Nginx 和 PHP-FPM 的配置。 通过上述步骤,可以完成 Nginx 和 PHP 的基本安装与配置。这将为后续 Web 应用的开发和部署打下坚实的基础。

    img LNMP环境搭建(php-5.6.19 nginx-1.9.12 mysql-5.6.19)配置.docx

    4. 配置编译选项,包括指定安装路径、启用PHP-FPM、CLI以及各种扩展:`./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fpm --enable-cli --enable-pcntl --enable-sockets --enable-...

    php7+nginx编译后的

    6. **启动服务**:启动Nginx和PHP-FPM服务。Nginx通常用`nginx -t`检查配置无误后,用`nginx`或`systemctl start nginx`启动;PHP-FPM则可能是`php-fpm`或`systemctl start php-fpm`。 7. **测试与优化**:通过访问...

    Linux下mysql+PHP+nginx的搭建(已测试)

    在Linux系统中搭建一个基于MySQL、PHP和Nginx的环境是常见的Web开发配置,这种组合通常被称为LAMP(Linux, Apache, MySQL, PHP)架构,但在本例中使用的是Nginx代替Apache,所以是LNMP(Linux, Nginx, MySQL, PHP)...

    centos 7 nginx php

    ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-fpm-user=nginx --with-fpm-group=nginx --enable-fpm --with-...

    php-5.2.6 fpm配套包

    在配置阶段,需确保开启FPM支持,通常通过`--with-fpm`选项来指定。完成编译后,进行必要的系统环境变量设置,以便正确启动和管理PHP FPM服务。 2. **FPM配置文件**:FPM的配置文件通常位于`/etc/php-fpm.conf`或`/...

    构架Nginx+PHP(Fastcgi)+MySQL+Memcache高性能web服务器

    ### 构建Nginx+PHP(Fastcgi)+MySQL+Memcache高性能Web服务器 #### 一、概述 本文档旨在详细介绍如何构建一个基于Nginx、PHP(Fastcgi)、MySQL以及Memcache的高性能Web服务器架构(简称LEMP+...-group=nginx --with-...

Global site tag (gtag.js) - Google Analytics