Httpd服务进阶知识-基于FASTCGI实现的LAMP架构
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.httpd+php结合的方式
module: php fastcgi : php-fpm php-fpm: CentOS 6: PHP-5.3.2之前:默认不支持fpm机制;需要自行打补丁并编译安装 httpd-2.2:默认不支持fcgi协议,需要自行编译此模块 解决方案:编译安装httpd-2.4, php-5.3.3+
CentOS 7: httpd-2.4:rpm包默认编译支持fcgi模块 php-fpm包:专用于将php运行于fpm模式
二.配置fastcgi实验准备
1>.虚拟机配置
[root@node101.yinzhengjie.org.cn ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# uname -r 3.10.0-957.el7.x86_64 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# uname -m x86_64 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# free -h total used free shared buff/cache available Mem: 3.7G 694M 1.4G 20M 1.6G 2.7G Swap: 3.9G 0B 3.9G [root@node101.yinzhengjie.org.cn ~]#
2>.角色分配
node101.yinzhengjie.org.cn:
HTTPD服务器
node102.yinzhengjie.org.cn:
FASTCGI服务器
node103.yinzhengjie.org.cn:
MariaDB服务器
三.基于FASTCGI方式实现连接数据库案例实战
1>.node101.yinzhengjie.org.cn节点操作
[root@node101.yinzhengjie.org.cn ~]# yum -y install httpd Loaded plugins: fastestmirror Determining fastest mirrors * base: mirror.bit.edu.cn * extras: mirror.bit.edu.cn * updates: mirrors.huaweicloud.com base | 3.6 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/4): base/7/x86_64/group_gz | 165 kB 00:00:00 (2/4): extras/7/x86_64/primary_db | 153 kB 00:00:00 (3/4): updates/7/x86_64/primary_db | 5.8 MB 00:00:00 (4/4): base/7/x86_64/primary_db | 6.0 MB 00:00:03 Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-90.el7.centos will be installed --> Processing Dependency: httpd-tools = 2.4.6-90.el7.centos for package: httpd-2.4.6-90.el7.centos.x86_64 --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-90.el7.centos.x86_64 --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-90.el7.centos.x86_64 --> Running transaction check ---> Package apr.x86_64 0:1.4.8-5.el7 will be installed ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed ---> Package httpd-tools.x86_64 0:2.4.6-90.el7.centos will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================ Installing: httpd x86_64 2.4.6-90.el7.centos base 2.7 M Installing for dependencies: apr x86_64 1.4.8-5.el7 base 103 k apr-util x86_64 1.5.2-6.el7 base 92 k httpd-tools x86_64 2.4.6-90.el7.centos base 91 k Transaction Summary ============================================================================================================================================================================ Install 1 Package (+3 Dependent packages) Total download size: 3.0 M Installed size: 9.9 M Downloading packages: (1/4): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:00 (2/4): apr-1.4.8-5.el7.x86_64.rpm | 103 kB 00:00:01 (3/4): httpd-2.4.6-90.el7.centos.x86_64.rpm | 2.7 MB 00:00:01 (4/4): httpd-tools-2.4.6-90.el7.centos.x86_64.rpm | 91 kB 00:00:00 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 1.7 MB/s | 3.0 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : apr-1.4.8-5.el7.x86_64 1/4 Installing : apr-util-1.5.2-6.el7.x86_64 2/4 Installing : httpd-tools-2.4.6-90.el7.centos.x86_64 3/4 Installing : httpd-2.4.6-90.el7.centos.x86_64 4/4 Verifying : apr-1.4.8-5.el7.x86_64 1/4 Verifying : httpd-tools-2.4.6-90.el7.centos.x86_64 2/4 Verifying : apr-util-1.5.2-6.el7.x86_64 3/4 Verifying : httpd-2.4.6-90.el7.centos.x86_64 4/4 Installed: httpd.x86_64 0:2.4.6-90.el7.centos Dependency Installed: apr.x86_64 0:1.4.8-5.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-90.el7.centos Complete! [root@node101.yinzhengjie.org.cn ~]#