centos6.10 php-5.6.37安装

centos6.10 php-5.6.37安装 

一、下载php-5.6.37.tar.gz

 window下载:http://php.net/downloads.php

 linux下载:wget $url

   $url  怎么获取? --->  在Windows中用浏览器打开http://php.net/downloads.php选择对应的版本下载,然后打开浏览器的下载列表,在里面查看下载的url

[root@localhost src]# wget http://cn2.php.net/distributions/php-5.6.37.tar.gz

二、解压【到指定目录】

[root@localhost src]# tar zxvf php-5.6.37.tar.gz -C /usr/local/webserver

三、环境准备【安装相应的依赖】

[root@localhost src]# yum -y install gd libxml2-devel libjpeg-devel libpng-devel

四、编译,安装PHP

[root@localhost src]# cd /usr/local/webserver/php-5.6.37

下面一行,红色的为必须,其他的根据需要考虑下 [root@localhost php
-5.6.37]# ./configure --prefix=/usr/local/webserver/php5637 --with-gd --with-zlib --with-mysql --enable-mbstring --enable-fpm
过程太长省略,下面是结果
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands

[root@localhost php-5.6.37]# make
过程太长省略了,下面结果
Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
directorytreeiterator.inc
invertedregexiterator.inc
directorygraphiterator.inc
pharcommand.inc
phar.inc

Build complete.
Don't forget to run 'make test'.
[root@localhost php-5.6.37]# make install
过程太长省略了,下面结果
Installing shared extensions:     /usr/local/webserver/php5637/lib/php/extensions/no-debug-non-zts-20131226/
Installing PHP CLI binary:       /usr/local/webserver/php5637/bin/
Installing PHP CLI man page:      /usr/local/webserver/php5637/php/man/man1/
Installing PHP CGI binary:        /usr/local/webserver/php5637/bin/
Installing PHP CGI man page:      /usr/local/webserver/php5637/php/man/man1/
Installing build environment:     /usr/local/webserver/php5637/lib/php/build/
Installing header files:          /usr/local/webserver/php5637/include/php/
Installing helper programs:      /usr/local/webserver/php5637/bin/
  program: phpize
  program: php-config
Installing man pages:            /usr/local/webserver/php5637/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/webserver/php5637/lib/php/
[PEAR] Archive_Tar    - installed: 1.3.12
[PEAR] Console_Getopt - installed: 1.3.1
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util       - installed: 1.2.3
[PEAR] PEAR           - installed: 1.9.5
Wrote PEAR system config file at:/usr/local/webserver/php5637/etc/pear.conf 
You may want to add: /usr/etc/php/lib/php to your php.ini 
include_path /usr/local/webserver/php5637/build/shtool install -c ext/phar/phar.phar /usr/local/webserver/php55637/bin 
ln -s -f phar.phar /usr/local/webserver/php5637/bin/phar 
Installing PDO headers:/usr/local/webserver/php5637/include/php/ext/pdo/

到此编译安装完毕,不过还需要进行相关的配置

五、配置PHP

1、从解压包中复制php.ini到php的安装

[看你自己的情况是选择复制php.ini-development 还是 php.ini-product]

  

[root@localhost php-5.6.37]# pwd
/usr/local/webserver/php-5.6.37
[root@localhost php-5.6.37]# ll | grep php.ini
-rw-r--r--.  1 1000 1000   73654 7月  19 23:01 php.ini-development
-rw-r--r--.  1 1000 1000   73685 7月  19 23:01 php.ini-production
[root@localhost php-5.6.37]# cp php.ini-development /usr/local/webserver/php5637/etc/php.ini
[root@localhost php-5.6.37]#  cd /usr/local/webserver/php5637/etc
[root@localhost etc]# ll
总用量 100
-rw-r--r--. 1 root root  1387 8月   5 18:39 pear.conf
-rw-r--r--. 1 root root 23155 8月   5 18:56 php-fpm.conf
-rw-r--r--. 1 root root 73654 8月   5 18:58 php.ini

2、配置php

[root@localhost ~]#cd /usr/local/webserver/php5637/etc/
[root@localhost etc]#cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# vim php.ini
;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /usr/local/webserver/php5637/var
; Default Value: none
pid = run/php-fpm.pid


;       will be used.
;下面的这个你可以看着配置一下
user = nobody
group = nobody

3、配置php-fpm,启动php-fpm服务,配置开机启动

[root@localhost ~]#cd /usr/local/webserver/php-5.6.37
[root@localhost php-5.6.37]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-5.6.37]# chmod +x /etc/init.d/php-fpm
 
[root@localhost php-5.6.37]# chkconfig --add php-fpm
[root@localhost php-5.6.37]# chkconfig on php-fpm
[root@localhost php-5.6.37]# service php-fpm start

  

3、配置 nginx 支持 php 环境

  进入nginx安装目录 下的conf目录的nginx.conf文件 

[root@localhost conf]# vim nginx.conf
        # 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;
        }

 #取消FastCGI server部分location的注释,注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径

    进入nginx安装目录下的sbin目录下,判断nginx配置文件是否正确 

[root@localhost sbin]#./nginx -t
nginx: the configuration file /usr/local/webserver/ngin/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/webserver/ngin/conf/nginx.conf test is successful

  

六、测试

  略

  

下载

猜你喜欢

转载自www.cnblogs.com/hysen/p/9427837.html