转载自:http://blog.csdn.net/u014236259/article/details/54143211
1.安装libxml2
- http://ftp.osuosl.org/pub/blfs/conglomeration/libxml2/ 下载最新的libxml2源码包
- shell># wget http://ftp.osuosl.org/pub/blfs/conglomeration/libxml2/libxml2-2.7.2.tar.gz
- shell># tar zxvf libxml2-2.7.2.tar.gz
- shell># cd libxml2-2.7.2.
- shell>#./configure --prefix=/usr/local/libxml2 \
- --without-zlib
- shell># make && make install
2.安装jpeg8
- http://www.ijg.org/files/ 下载最新的jpeg源码包
- shell># wget http://www.ijg.org/files/jpegsrc.v8b.tar.gz
- shell># tar -zxvf jpegsrc.v8b.tar.gz
- shell># cd jpeg-8b
- shell>#./configure --prefix=/usr/local/jpeg \
- --enable-shared --enable-static
- shell># make && make install
- --enable-shared 把jpeg需要的函数库程序都编译到该软件里边
- 优点:函数调用速度快
- 缺点:软件本身比较大
- --enable-static 静态方式函数处理,需要什么函数,马上include来
- 优点:软件本身比较小
- 缺点:函数调用速度慢
3.安装zlib库(gzip压缩)
- ftp://ftp.simplesystems.org/pub/png/src/zlib 下载最新的 zlib 源码包
- shell>#wget ftp://ftp.simplesystems.org/pub/png/src/zlib/zlib-1.2.10.tar.gz
- shell>#tar -zxvf zlib-1.2.10.tar.gz
- shell>#cd zlib-1.2.10
- shell>#./configure && make && make install
4.安装libpng
- ftp://ftp.simplesystems.org/pub/png/src/ 下载最新的libpng源码包
- shell># wget ftp://ftp.simplesystems.org/pub/png/src/libpng14/libpng-1.4.3.tar.gz
- shell># tar zxvf libpng-1.4.3.tar.gz
- shell># cd libpng-1.4.3
- shell>#./configure #和zlib一样不要带参数,让它默认安装到相应目录
- shell># make && make install
5.安装freetype(字体库)
- http://download-mirror.savannah.gnu.org/releases/freetype/ 下载最新的freetype源码包
- shell># wget http://download-mirror.savannah.gnu.org/releases/freetype/freetype-2.4.1.tar.gz
- shell># tar zxvf freetype-2.4.1.tar.gz
- shell># cd freetype-2.4.1
- shell>#./configure --prefix=/usr/local/freetype
- shell># make && make install
6.安装GD库
- https://github.com/libgd/libgd/releases 下载最新的GD库源码包
- shell># wget https://github.com/libgd/libgd/releases/download/gd-2.1.1/libgd-2.1.1.tar.gz
- shell># tar -zvxf libgd-2.1.1.tar.gz
- shell># cd libgd-2.1.1
- shell>#./configure --prefix=/usr/local/gd \
- --with-jpeg=/usr/local/jpeg/ \
- --with-freetype=/usr/local/freetype
- shell># make && make install
7.安装ssl(某些vps默认没装ssl)
- shell>#wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
- shell>#tar -zxvf openssl-1.0.1c.tar.gz
- shell>#./config && make && make install
8.安装 php-5.6.19
- http://ftp.ntu.edu.tw/php/distributions/ 下载最新的php源码包
- shell># wget http://ftp.ntu.edu.tw/php/distributions/php-5.6.19.tar.gz
- shell># tar -jxvf php-5.6.19.tar.bz2
- shell># cd php-5.6.19
- shell>#./configure --prefix=/usr/local/web/php \
- --with-mysql=mysqlnd \
- --with-pdo-mysql=mysqlnd \
- --with-mysqli=mysqlnd \
- --with-freetype-dir=/usr/local/freetype \
- --with-gd=/usr/local/gd \
- --with-zlib --with-libxml-dir=/usr/local/libxml2 \
- --with-jpeg-dir=/usr/local/jpeg \
- --with-png-dir \
- --enable-mbstring=all \
- --enable-mbregex \
- --enable-shared \
- --with-openssl \
- --enable-fpm \
- --with-config-file-path=/usr/local/web/php/etc \
- --with-xpm-dir=/usr/lib \
- --enable-phpdbg #PHPDBG的目标是成为一个轻量级、强大、易用的PHP调试平台。
- 可以在PHP5.4和之上版本中使用。在php5.6和之上版本将内部集成。
-
- shell># make && make install
-
- #复制php.ini配置文件到指定目录
- shell># cp php.ini-development /usr/local/php/etc/php.ini
- shell># cd /usr/local/php/etc
- shell># cp ./php-fpm.conf.default ./php-fpm.conf
-
- #启动php服务
- shell># /usr/local/php/sbin/php-fpm
- #关闭php服务
- shell># killall php-fpm
-
- #设置软连接
- ln -sf /usr/local/web/php/sbin/php-fpm /usr/bin/php
9、如果出现错误:
/home/php-packge/php-5.6.19/ext/gd/gd.c:57:22: error: X11/xpm.h: No such file or directory
make: *** [ext/gd/gd.lo] Error 1
- #解决办法如下:
- yum install libXpm-devel
- #查询他的安装位置:
- #rpm -ql libXpm-devel
- /usr/bin/cxpm
- /usr/bin/sxpm
- /usr/include/X11/xpm.h
- /usr/lib/libXpm.so
- /usr/lib/pkgconfig/xpm.pc
- /usr/share/man/man1/cxpm.1.gz
- /usr/share/man/man1/sxpm.1.gz
- #在PHP的./configure配置中添加:
- --with-xpm-dir=/usr/lib
- #然后重新对php进行编译安装
注意:在自己的开发环境里面,没有root权限,想了几种方法安装上了libXpm,重新安装了gd,但是仍然报这个错,后来
直接跳过gd库,在安装php的时候不装gd扩展了,后期有需要的话再单独编译安装php扩展
./configure --prefix=$HOME/local/php --with-mysql=$HOME/local/mysql --with-freetype-dir=$HOME/local/freetype--with-gd=$HOME/local/gd --with-zlib=$HOME/local/zlib --with-libxml-dir=$HOME/local/libxml2 --with-jpeg-dir=$HOME/local/jpeg --with-png-dir=$HOME/local/png --enable-mbstring=all--with-config-file-path=$HOME/local/php/etc --with-xpm-dir=$HOME/local/lib --enable-phpdbg --enable-shared --with-openssl --enable-fpm
紫色的这句话没有起作用,后期装PHP扩展修改php.ini 文件的时候出来不少问题
查找php.ini 路径
10、修改nginx配置文件以支持php-fpm
- nginx和PHP安装完成后,修改nginx配置文件为,nginx.conf
-
- 其中server段增加如下配置,注意标红内容配置,否则会出现No input file specified.错误
-
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- location ~ .php$ {
- root html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- }
如下图所示,表示PHP安装成功!