- 浏览: 2489831 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
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/
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/
发表评论
-
PHP Command Line Tool
2019-08-17 05:06 359PHP Command Line Tool Recently ... -
Code SonarQube 2019(2)PostgreSQL as Database
2019-07-24 05:32 379Code SonarQube 2019(2)PostgreSQ ... -
Code SonarQube 2019(1)Installation with default H2
2019-07-23 10:42 739Code SonarQube 2019(1)Installat ... -
Auth Solution(3)JWT in Java and PHP Sample
2019-05-03 07:33 286Auth Solution(3)JWT in Java and ... -
Flarum BBS System(2)Docker the BBS
2018-11-20 03:31 607Flarum BBS System(2)Docker the ... -
Flarum BBS System(1)Installation and Introduction
2018-11-18 14:29 464Flarum BBS System(1)Installatio ... -
Grav CMS System(5)Multiple Domains and Certs
2018-11-15 01:48 497Grav CMS System(5)Multiple Doma ... -
Grav CMS System(4)Multiple Domain Sites in HAProxy and HTTPS
2018-11-14 21:33 554Grav CMS System(4)Multiple Doma ... -
Grav CMS System(3)Docker Nginx and PHP
2018-11-14 00:21 430Grav CMS System(3)Docker Nginx ... -
Grav CMS System(1)Install PHP7 on MAC
2018-10-23 21:53 544Grav CMS System(1)Install PHP7 ... -
Laravel PHP Framework(1)Introduction and Installation
2018-08-22 02:47 956Laravel PHP Framework(1)Introdu ... -
JSON Log in PHP and Cloud Watch(1)JSON Format in PHP
2017-12-30 05:31 566JSON Log in PHP and Cloud Watch ... -
PHPRedis Library
2017-03-30 00:32 645PHPRedis Library We can instal ... -
PHP Call Wget Command
2017-03-24 23:35 642PHP Call Wget Command In my PH ... -
PHP XML Writer
2017-03-10 03:59 1426PHP XML Writer PHP XML writer ... -
PHP Redis Client and Cluster
2017-02-16 03:34 616PHP Redis Client and Cluster S ... -
PHP Redis Client and Replica
2017-02-16 01:11 558PHP Redis Client and Replica W ... -
PHP HTTP Library and Error Handling
2017-02-11 06:19 604PHP HTTP Library and Error Hand ... -
PHP ENV and HTTP Extension
2017-01-12 01:04 763PHP ENV and HTTP Extension We ... -
PHP Connect Redis Driver
2016-11-23 00:29 550PHP Connect Redis Driver I was ...
相关推荐
PHP-FPM 是一个 PHP FastCGI 管理器,一般 Nginx 上面跑 PHP 程序都会将 PHP 程序丢给 PHP-FPM 来解析。好了,就这样! PHP 5.4 开始集成了 PHP-FPM ,也就是说编译 PHP 时,只要 –enable-fpm 就装好了 PHP-FPM 。 ...
php5-nginx-vagrant-sample使用 Vagrant 自动设置 PHP 和 MySQL 工作的环境。 将其视为不依赖于操作系统的 XAMPP / MAMP 之类的东西。我还设置了 PostgreSQL 和 ImageMagick。 操作系统Ubuntu 12.04 LTS (GNU/Linux ...
listen = /tmp/php-fcgi.sock // 监听的地址,可以监听socket ,也可以监听端口 listen = 127.0.0.1:8089 或者这样写,php-fpm 通常在本地使用,php和nginx 通常在一台机器,所以可写127.0.0.1,别的机器 连接,需用...
docker run -d --volumes-from=web-data -p=80:80 --name=prestashop johnnyzheng/nginx-php-prestashop 定制 Prestashop 安装参数可以在 docker 环境变量中指定。 参数包括: 领域 语 时区 SHOP_NAME SHOP_EMAIL ...
Docker结合最新的php-fpm,nginx,redis,memcached,mariadb和git,nodejs,yarn等常用工具 此仓库与和相关联 如果您正在寻找LNMongoP,请转到 php-fpm 有关更多信息,请访问 Nginx的 有关更多信息,请访问 工具 ...
listen = /tmp/php-fcgi.sock // 监听的地址,可以监听socket ,也可以监听端口 listen = 127.0.0.1:8089 或者这样写,php-fpm 通常在本地使用,php和nginx 通常在一台机器,所以可写127.0.0.1,别的机器 连接,需用...
listen = /tmp/php-fcgi.sock // 监听的地址,可以监听socket ,也可以监听端口 listen = 127.0.0.1:8089 或者这样写,php-fpm 通常在本地使用,php和nginx 通常在一台机器,所以可写127.0.0.1,别的机器 连接,需用...
listen = /tmp/php-fcgi.sock // 监听的地址,可以监听socket ,也可以监听端口 listen = 127.0.0.1:8089 或者这样写,php-fpm 通常在本地使用,php和nginx 通常在一台机器,所以可写127.0.0.1,别的机器 连接,需用...
listen = 127.0.0.1:8089 或者这样写,php-fpm 通常在本地使用,php和nginx 通常在一台机器,所以可写127.0.0.1,别的机器 连接,需用本机ip listen.mode = 666 //sock 文件的权限 listen.owner = nobody listen....
listen = /tmp/php-fcgi.sock // 监听的地址,可以监听socket ,也可以监听端口 listen = 127.0.0.1:8089 或者这样写,php-fpm 通常在本地使用,php和nginx 通常在一台机器,所以可写127.0.0.1,别的机器 连接,需用...
常见的Nginx 502 Bad Gateway解决办法如下: Nginx 502错误情况1: 网站的访问量大,而php-cgi的进程数偏少。 针对这种情况的502错误,只需增加php-cgi的进程数。具体就是修改/usr/local/php/etc/php-fpm.conf ...
WorPress docker映像,由nginx / php-fpm组合提供支持,由s6主管管理。 尝试修复几个WordPress反模式以准备部署容器 自动插件安装程序 WARNING: This feature is experimental and can fail. Proceed with caution ...
Magento 2码头工人 Docker映像的集合,用于通过nginx和在命令行上运行Magento 2。快速开始cp composer.env.sample composer.env# ..put the correct tokens into composer.envmkdir magentodocker-compose run cli ...
docker-compose服务: php-fpm Nginx的MySQL的Redisphp扩展名: Redis woo用法使用laravel的示例: 步骤1:使用composer安装laravel:./bin/composer create-project --prefer-dist laravel/laravel www 步骤2:使用...
本文实例讲述了linux平台编译安装PHP7并安装Redis扩展与Swoole扩展的方法。分享给大家供大家参考,具体如下: ...本php7是编译成fpm-php 使用的,如果是apache那么编译参数应该为 --with-apxs2=/usr/local/apa
PHP 5.5.1(最新稳定版,支持PHP-FPM(独家首创Windows版本),实现PHP-CGI进程智能管理。温馨提示:PHP5.5.x不再支持XP和2003,需要5.2(可在纯PE下使用)、5.3、5.4的朋友请下相应的版本;需要包含wordpress演示...
)欲了解更多信息,请访问http//tool.chinaz.com/pagestatus/)PHP 5.4.17(稳定版,支持PHP-FPM(独家首创Windows版本),实现PHP-CGI进程智能管理。温馨提示:PHP5.5.x不再支持XP和2003。需要5.2(可在纯PE下使用...
NGINX,PHP-FPM 7.2,MySQL 5.7,phpMyAdmin,Redis,RabbitMQ 使用Graylog集中记录您本地环境上的自动HTTPS 强大的反向代理( ),可以在生产环境中处理自动HTTPS(通过 ) 使用或Docker for Mac的用户引导缓存在...
莫维科 Moovico 是一个快速且可扩展的 MVC 框架和...) - 在 lighttpd/php-cgi 和 nginx/php-fpm 上测试 PHP >= 5.3 with mysqli-support 如果你想使用连接器。 执照 所有工作都是开源的,并在 BSD 许可下获得许可。
# generate configuration file with default template (PHP-FPM) $ apache-to-nginx /etc/apache2/sites-available/example.com.conf /etc/nginx/site-available # generate configuration file with custom ...