1.å¦ä½å¨ç³»ç»å®è£
ARGB
2.PHP-FPM详解
3.使用Dockerfile基于7.4-fpm-buster镜像搭建php7.4微服务环境
å¦ä½å¨ç³»ç»å®è£ ARGB
nginx php-fpmå®è£ é ç½®nginxæ¬èº«ä¸è½å¤çPHPï¼å®åªæ¯ä¸ªwebæå¡å¨ï¼å½æ¥æ¶å°è¯·æ±åï¼å¦ææ¯php请æ±ï¼ååç»php解éå¨å¤çï¼å¹¶æç»æè¿åç»å®¢æ·ç«¯ã
nginxä¸è¬æ¯æ请æ±åfastcgi管çè¿ç¨å¤çï¼fascgi管çè¿ç¨éæ©cgiåè¿ç¨å¤çç»æ并è¿å被nginx
æ¬æ以php-fpm为ä¾ä»ç»å¦ä½ä½¿nginxæ¯æPHP
ä¸ãç¼è¯å®è£ php-fpm
ä»ä¹æ¯PHP-FPM
PHP-FPMæ¯ä¸ä¸ªPHP FastCGI管çå¨ï¼æ¯åªç¨äºPHPç,包源å¯ä»¥å¨ 2.php.net/distributions/php-5.4.7.tar.gztar zvxf php-5.4.7.tar.gz
cd php-5.4.7./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt \--enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath \--enable-inline-optimization --with-bz2 --with-zlib --enable-sockets \--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \--with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli \--with-gd --with-jpeg-dir
make all install
æ§çæå¨æè¡¥ä¸php-fpmå®è£ ï¼æ§çç¨åºå·²ç»æ²¡æäºï¼å¤§å®¶æ°ççå§ï¼è¿éå个å±ç¤ºï¼
wget 2.php.net/get/php-5.2..tar.gz
wget tl -enable-sockets -with-bz2 -with-curl -with-curlwrappers\
-enable-mbregex -with-gd -enable-gd-native-ttf -enable-zip -enable-soap -with-iconv -enable-bcmath\
-enable-shmop -enable-sysvsem -enable-inline-optimization -with-ldap -with-ldap-sasl -enable-pdo\
-with-pdo-mysql
make all install
以ä¸ä¸¤ç§æ¹å¼é½å¯ä»¥å®è£ php-fpmï¼å®è£ åå 容æ¾å¨/usr/local/phpç®å½ä¸
以ä¸å°±å®æäºphp-fpmçå®è£ ã
ä¸é¢æ¯å¯¹php-fpmè¿è¡ç¨æ·è¿è¡è®¾ç½®
cd /usr/local/php
cp etc/php-fpm.conf.default etc/php-fpm.conf
vi etc/php-fpm.conf
ä¿®æ¹
user = www-data
group = www-data
å¦æwww-dataç¨æ·ä¸åå¨ï¼é£ä¹å æ·»å www-dataç¨æ·
groupadd www-data
useradd -g www-data www-data
äºãç¼è¯å®è£ nginx
ç¶ånginxï¼
nginxå¯ä»¥ä½¿ç¨åå¹³å°çé»è®¤å æ¥å®è£ ï¼æ¬ææ¯ä»ç»ä½¿ç¨æºç ç¼è¯å®è£ ï¼å æ¬å ·ä½çç¼è¯åæ°ä¿¡æ¯ã
æ£å¼å¼å§åï¼ç¼è¯ç¯å¢gcc g++ å¼ååºä¹ç±»çéè¦æåè£ å¥½ï¼è¿éé»è®¤ä½ å·²ç»è£ 好ã
ububtuå¹³å°ç¼è¯ç¯å¢å¯ä»¥ä½¿ç¨ä»¥ä¸æ令
1
2
apt-get install build-essential
apt-get install libtool
centoså¹³å°ç¼è¯ç¯å¢ä½¿ç¨å¦ä¸æ令
å®è£ makeï¼
1
yum -y install gcc automake autoconf libtool make
å®è£ g++:
1
yum install gcc gcc-c++
ä¸é¢æ£å¼å¼å§
---------------------------------------------------------------------------
ä¸è¬æ们é½éè¦å è£ pcre, zlibï¼åè 为äºéårewriteï¼åè 为äºgzipå缩ã
1.éå®æºç ç®å½
å¯ä»¥æ¯ä»»ä½ç®å½ï¼æ¬æéå®çæ¯/usr/local/src
1
cd /usr/local/src
2.å®è£ PCREåº
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ ä¸è½½ææ°ç PCRE æºç å ï¼ä½¿ç¨ä¸é¢å½ä»¤ä¸è½½ç¼è¯åå®è£ PCRE å ï¼
1
2
3
4
5
6
7
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8..tar.gz
tar -zxvf pcre-8..tar.gz
cd pcre-8.
./configure
make
make install
3.å®è£ zlibåº
e to nginx! å表示 Nginx å·²ç»å®è£ 并è¿è¡æåã
-----------------------------------------------------
å°è¿énginxå°±å®è£ å®æäºï¼å¦æåªæ¯å¤çéæhtmlå°±ä¸ç¨ç»§ç»å®è£ äº
å¦æä½ éè¦å¤çphpèæ¬çè¯ï¼è¿éè¦å®è£ php-fpmã
ä¸é¢å®è£ æé
éï¼å¯è½éå°çé误åä¸äºå¸®å©ä¿¡æ¯
1.1ç¼è¯pcreé误
1
2
3
4
5
libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] Error 1
make[1]: Leaving directory `/usr/local/src/pcre-8.'
make: *** [all] Error 2
解å³åæ³ï¼å®è£ g++,å«å¿äºéæ°configure
1
2
3
4
5
apt-get install g++
apt-get install build-essential
make clean
./configure
make
1.2 makeåºé
1
2
3
4
5
make: *** No rule to make target `build', needed by `default'. Stop.
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
æç §ç¬¬4æ¥çå®è£ æ¹æ³æ
ubuntuä¸
1
2
apt-get install openssl
apt-get install libssl-dev
centosä¸
1
yum -y install openssl openssl-devel
2.nginxç¼è¯é项
makeæ¯ç¨æ¥ç¼è¯çï¼å®ä»Makefileä¸è¯»åæ令ï¼ç¶åç¼è¯ã
make installæ¯ç¨æ¥å®è£ çï¼å®ä¹ä»Makefileä¸è¯»åæ令ï¼å®è£ å°æå®çä½ç½®ã
configureå½ä»¤æ¯ç¨æ¥æ£æµä½ çå®è£ å¹³å°çç®æ ç¹å¾çãå®å®ä¹äºç³»ç»çå个æ¹é¢ï¼å æ¬nginxç被å 许使ç¨çè¿æ¥å¤ççæ¹æ³ï¼æ¯å¦å®ä¼æ£æµä½ æ¯ä¸æ¯æCCæGCCï¼å¹¶ä¸æ¯éè¦CCæGCCï¼å®æ¯ä¸ªshellèæ¬ï¼æ§è¡ç»ææ¶ï¼å®ä¼å建ä¸ä¸ªMakefileæ件ãnginxçconfigureå½ä»¤æ¯æ以ä¸åæ°ï¼
--prefix=path å®ä¹ä¸ä¸ªç®å½ï¼åæ¾æå¡å¨ä¸çæ件 ï¼ä¹å°±æ¯nginxçå®è£ ç®å½ãé»è®¤ä½¿ç¨ /usr/local/nginxã
--sbin-path=path 设置nginxçå¯æ§è¡æ件çè·¯å¾ï¼é»è®¤ä¸º prefix/sbin/nginx.
--conf-path=path 设置å¨nginx.confé ç½®æ件çè·¯å¾ãnginxå 许使ç¨ä¸åçé ç½®æ件å¯å¨ï¼éè¿å½ä»¤è¡ä¸ç-cé项ãé»è®¤ä¸ºprefix/conf/nginx.conf.
--pid-path=path 设置nginx.pidæ件ï¼å°åå¨ç主è¿ç¨çè¿ç¨å·ãå®è£ å®æåï¼å¯ä»¥éæ¶æ¹åçæ件å ï¼ å¨nginx.confé ç½®æ件ä¸ä½¿ç¨ PIDæ令ãé»è®¤æ åµä¸ï¼æ件å 为prefix/logs/nginx.pid.
--error-log-path=path 设置主é误ï¼è¦åï¼åè¯ææ件çå称ãå®è£ å®æåï¼å¯ä»¥éæ¶æ¹åçæ件å ï¼å¨nginx.confé ç½®æä»¶ä¸ ä½¿ç¨ çerror_logæ令ãé»è®¤æ åµä¸ï¼æ件å 为prefix/logs/error.log.
--pilationâï¼1.1.ä¸ï¼ pcre_jitæ令ï¼ã
--with-zlib=path â设置çzlibåºçæºç è·¯å¾ãè¦ä¸è½½ä» zlibï¼çæ¬1.1.3 - 1.2.5ï¼ç并解åãå ¶ä½çå·¥ä½æ¯Nginxç./ configureåmakeå®æãngx_pose发布,避免了与apache不兼容的源码困扰。
选择的包源php镜像版本是php:7.4-fpm-buster,基于debian操作系统。源码首先,包源微源码公司我们拉取镜像并启动临时容器,源码苹果采集源码检查其内部结构,包源包括php程序、源码配置文件和fpm组件。包源通过端口映射,源码便于与nginx容器配合运行。包源
如果需要php源代码,源码可以使用docker-php-source命令导入和删除。包源epoll 源码解析安装php扩展,源码例如mysql,包源使用docker-php-ext-install,配置参数则通过docker-php-ext-configure,archlinux 安装源码启用扩展则用docker-php-ext-enable。福哥通过在临时容器手动安装环境,然后整理到Dockerfile中,以清晰展示整个过程。菜单翻转源码
Dockerfile中包含了apt更新、依赖库和工具安装、配置文件设置、时区调整、测试验证等步骤。最终,通过Dockerfile,我们可以直接基于7.4-fpm-buster镜像搭建出php7.4的微服务环境,极大地简化了基础环境配置。
下一课,将继续利用Dockerfile的技巧,构建TFUMS项目的运行环境,敬请期待。
2024-11-23 12:29
2024-11-23 12:21
2024-11-23 12:11
2024-11-23 12:05
2024-11-23 11:49
2024-11-23 11:28
2024-11-23 10:20
2024-11-23 10:02