centos 安装配置php,nginx

转载自:http://blog.csdn.net/u014236259/article/details/54143211 

                    

1.安装libxml2

[html]  view plain  copy
  1. http://ftp.osuosl.org/pub/blfs/conglomeration/libxml2/  下载最新的libxml2源码包  
  2. shell># wget http://ftp.osuosl.org/pub/blfs/conglomeration/libxml2/libxml2-2.7.2.tar.gz  
  3. shell># tar zxvf libxml2-2.7.2.tar.gz   
  4. shell># cd libxml2-2.7.2.  
  5. shell>#./configure --prefix=/usr/local/libxml2  \  
  6. --without-zlib  
  7. shell># make && make install  

2.安装jpeg8

[html]  view plain  copy
  1. http://www.ijg.org/files/    下载最新的jpeg源码包  
  2. shell># wget http://www.ijg.org/files/jpegsrc.v8b.tar.gz  
  3. shell># tar -zxvf jpegsrc.v8b.tar.gz  
  4. shell># cd jpeg-8b  
  5. shell>#./configure --prefix=/usr/local/jpeg \  
  6. --enable-shared --enable-static   
  7. shell># make && make install  
  8. --enable-shared  把jpeg需要的函数库程序都编译到该软件里边  
  9.                   优点:函数调用速度快  
  10.         缺点:软件本身比较大  
  11. --enable-static   静态方式函数处理,需要什么函数,马上include来  
  12.               优点:软件本身比较小  
  13.               缺点:函数调用速度慢  

3.安装zlib库(gzip压缩)

[html]  view plain  copy
  1. ftp://ftp.simplesystems.org/pub/png/src/zlib 下载最新的 zlib 源码包  
  2. shell>#wget ftp://ftp.simplesystems.org/pub/png/src/zlib/zlib-1.2.10.tar.gz  
  3. shell>#tar -zxvf zlib-1.2.10.tar.gz  
  4. shell>#cd zlib-1.2.10  
  5. shell>#./configure && make && make install  

4.安装libpng

[html]  view plain  copy
  1. ftp://ftp.simplesystems.org/pub/png/src/   下载最新的libpng源码包  
  2. shell># wget ftp://ftp.simplesystems.org/pub/png/src/libpng14/libpng-1.4.3.tar.gz  
  3. shell># tar zxvf libpng-1.4.3.tar.gz   
  4. shell># cd libpng-1.4.3  
  5. shell>#./configure  #和zlib一样不要带参数,让它默认安装到相应目录  
  6. shell># make && make install  

5.安装freetype(字体库)

[html]  view plain  copy
  1. http://download-mirror.savannah.gnu.org/releases/freetype/   下载最新的freetype源码包  
  2. shell># wget http://download-mirror.savannah.gnu.org/releases/freetype/freetype-2.4.1.tar.gz  
  3. shell># tar zxvf freetype-2.4.1.tar.gz   
  4. shell># cd freetype-2.4.1  
  5. shell>#./configure --prefix=/usr/local/freetype  
  6. shell># make && make install  

6.安装GD库

[html]  view plain  copy
  1. https://github.com/libgd/libgd/releases  下载最新的GD库源码包  
  2. shell># wget  https://github.com/libgd/libgd/releases/download/gd-2.1.1/libgd-2.1.1.tar.gz  
  3. shell># tar -zvxf libgd-2.1.1.tar.gz  
  4. shell># cd libgd-2.1.1  
  5. shell>#./configure --prefix=/usr/local/gd  \  
  6. --with-jpeg=/usr/local/jpeg/    \  
  7. --with-freetype=/usr/local/freetype  
  8. shell># make && make install  


7.安装ssl(某些vps默认没装ssl)

[html]  view plain  copy
  1. shell>#wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz  
  2. shell>#tar -zxvf openssl-1.0.1c.tar.gz  
  3. shell>#./config && make && make install  

8.安装 php-5.6.19

[html]  view plain  copy
  1. http://ftp.ntu.edu.tw/php/distributions/    下载最新的php源码包  
  2. shell># wget  http://ftp.ntu.edu.tw/php/distributions/php-5.6.19.tar.gz  
  3. shell># tar -jxvf php-5.6.19.tar.bz2  
  4. shell># cd php-5.6.19  
  5. shell>#./configure --prefix=/usr/local/web/php \  
  6. --with-mysql=mysqlnd \  
  7. --with-pdo-mysql=mysqlnd \  
  8. --with-mysqli=mysqlnd \  
  9. --with-freetype-dir=/usr/local/freetype \  
  10. --with-gd=/usr/local/gd \  
  11. --with-zlib --with-libxml-dir=/usr/local/libxml2 \  
  12. --with-jpeg-dir=/usr/local/jpeg \  
  13. --with-png-dir \  
  14. --enable-mbstring=all \  
  15. --enable-mbregex \  
  16. --enable-shared \  
  17. --with-openssl \  
  18. --enable-fpm \  
  19. --with-config-file-path=/usr/local/web/php/etc \  
  20. --with-xpm-dir=/usr/lib \  
  21. --enable-phpdbg   #PHPDBG的目标是成为一个轻量级、强大、易用的PHP调试平台。  
  22. 可以在PHP5.4和之上版本中使用。在php5.6和之上版本将内部集成。  
  23.   
  24. shell># make && make install   
  25.   
  26. #复制php.ini配置文件到指定目录  
  27. shell># cp php.ini-development /usr/local/php/etc/php.ini  
  28. shell># cd /usr/local/php/etc  
  29. shell># cp ./php-fpm.conf.default ./php-fpm.conf  
  30.   
  31. #启动php服务  
  32. shell># /usr/local/php/sbin/php-fpm  
  33. #关闭php服务  
  34. shell>#  killall php-fpm  
  35.   
  36. #设置软连接  
  37. 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

[html]  view plain  copy
  1. #解决办法如下:  
  2. yum install libXpm-devel  
  3. #查询他的安装位置:  
  4. #rpm -ql libXpm-devel  
  5. /usr/bin/cxpm  
  6. /usr/bin/sxpm  
  7. /usr/include/X11/xpm.h  
  8. /usr/lib/libXpm.so  
  9. /usr/lib/pkgconfig/xpm.pc  
  10. /usr/share/man/man1/cxpm.1.gz  
  11. /usr/share/man/man1/sxpm.1.gz  
  12. #在PHP的./configure配置中添加:  
  13. --with-xpm-dir=/usr/lib  
  14. #然后重新对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

[html]  view plain  copy
  1. nginx和PHP安装完成后,修改nginx配置文件为,nginx.conf  
  2.   
  3. 其中server段增加如下配置,注意标红内容配置,否则会出现No input file specified.错误  
  4.   
  5. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
  6. #  
  7. location ~ .php$ {  
  8.     root html;  
  9.     fastcgi_pass 127.0.0.1:9000;  
  10.     fastcgi_index index.php;  
  11.     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  
  12.     include fastcgi_params;  
  13. }  


如下图所示,表示PHP安装成功!




猜你喜欢

转载自blog.csdn.net/Tifficial/article/details/78196346