LNMP源码编译安装之PHP-5.5.32

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LNMP源码编译安装之PHP-5.5.32相关的知识,希望对你有一定的参考价值。

一.FastCGI
技术分享图片
快速通用网关接口(socket),为HTTP服务器与其他机器上的程序服务通信交流工具常规web程序都支持。

LNMP运行过程和解析原理
技术分享图片
原理白话
用户访问nginxWeb服务器-Ngixn负责解析静态数据(jpg,gif,css,js,avi,html)也接受动态数据(.php)动态数据通过FastCGI接口后抛(fastcgi_pass监听 http://x.x.x.x:9000)给PHP服务器(php-fpm多个进程监听9000端口)[进程配置文件php-fpm.conf设置进程数量]监听到请求就会调用wrapper程序,wrapper会再启多个线程调用PHP解析器(引擎)进行解析,如要连数据库则向后数据库(dbip,root.pass.port3306)进行请求.数据库再将数据通过FastCGI将数据发给Nginx服务器后,Nginx再给用户

确定nginx与数据库是启动的

[[email protected] ~]# netstat -tunlp|egrep "3306|80"
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1657/mysqld         
tcp        0      0 0.0.0.0:80

检查php所需的;lib库

[[email protected] ~]# rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel 
libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64
libpng-devel-1.2.49-2.el6_7.x86_64
freetype-devel-2.3.11-17.el6.x86_64
gd-devel-2.0.35-11.el6.x86_64
libcurl-devel-7.19.7-53.el6_9.x86_64
zlib-devel-1.2.3-29.el6.x86_64
libxml2-devel-2.7.6-21.el6_8.1.x86_64

更新bash源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
更新epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

yum安装lib库及哈希程序

yum install -y  zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrypt-devel 
yum install -y  mcrypt mhash
cd /home/oldboy/tools/
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv

Centos7 下需要先操作如下

 cd  srclib/
sed -i -e ‘/gets is a security/d‘ ./stdio.in.h
|
make &&make install

再次确认基础库和扩展库程序是否安装齐全

[[email protected] tools]# rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrypt-devel  mcrypt  mhash
libxslt-devel-1.1.26-2.el6_3.1.x86_64
mhash-0.9.9.9-3.el6.x86_64
libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64
libmcrypt-devel-2.5.8-9.el6.x86_64
libpng-devel-1.2.49-2.el6_7.x86_64
freetype-devel-2.3.11-17.el6.x86_64
gd-devel-2.0.35-11.el6.x86_64
libcurl-devel-7.19.7-53.el6_9.x86_64
zlib-devel-1.2.3-29.el6.x86_64
libxml2-devel-2.7.6-21.el6_8.1.x86_64
mcrypt-2.6.8-10.el6.x86_64

要一步一检查

./configure --prefix=/application/php5.5.32 \--with-mysql=/application/mysql/ \--with-pdo-mysql=mysqlnd \--with-iconv-dir=/usr/local/libiconv \--with-freetype-dir \--with-jpeg-dir \--with-png-dir \--with-zlib \--with-libxml-dir=/usr \--enable-xml \--disable-rpath \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--with-curl \--enable-mbregex \--enable-fpm \--enable-mbstring \--with-mcrypt \--with-gd \--with-openssl \--with-mhash \--enable-gd-native-ttf \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-soap \--enable-short-tags \--enable-static \--with-xsl \--with-fpm-user=www \--with-fpm-group=www \--enable-ftp \--enable-opcache=no

技术分享图片

[[email protected] php-5.5.32]# ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
[[email protected] php-5.5.32]# touch ext/phar/phar.phar
编译
[[email protected] php-5.5.32]#make && make install

技术分享图片

[[email protected] php-5.5.32]# ln -s /application/php5.5.32/ /application/php
设置php-fpm主配置文件

[[email protected] php-5.5.32]# cp php.ini-production /application/php/lib/php.ini
[[email protected] php5.5.32]# cd /application/php/etc/
[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf
[[email protected] ~]# /application/php/sbin/php-fpm
[[email protected] ~]# lsof -i :9000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 30476 root 7u IPv4 155336 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 30477 www 0u IPv4 155336 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 30478 www 0u IPv4 155336 0t0 TCP localhost:cslistener (LISTEN)
[[email protected] ~]# netstat -tunlp|grep "php-fpm"
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 30476/php-fpm

以上是关于LNMP源码编译安装之PHP-5.5.32的主要内容,如果未能解决你的问题,请参考以下文章

web服务之源码编译安装LNMP

web服务之源码编译安装LNMP

源码编译lnmp之简介与nginx安装

源码编译lnmp之简介与nginx安装

源码编译lnmp之简介与nginx安装

LNMP源码编译安装之Mysql