CentOS编译安装PHP

Target Version:PHP 7.1

1. download php7.1

http://cn2.php.net/downloads.php

2. upload to server

so easy, just do it

3. configure install environment

yum groupinstall "Development Tools"
yum install libxml2-devel
yum install openssl-devel
yum install libcurl-devel
yum install gd-devel
yum install libmcrypt-devel
yum install libicu-devel.x86_64
yum install libxslt libxslt-devel.x86_64

4. compile && install

There are my configuration.

./configure --prefix=/usr/local/php7.1 \
--with-config-file-path=/usr/local/php7.1/etc \
--with-config-file-scan-dir=/usr/local/php7.1/etc/php.d \
--enable-opcache \
--enable-fpm \
--with-gd \
--with-zlib \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-pdo-mysql=mysqlnd \
--enable-sockets \
--with-mcrypt \
--with-openssl \
--enable-bcmath \
--with-curl \
--enable-intl \
--enable-mbstring \
--enable-soap \
--with-xsl \
--enable-zip \
--with-mysqli 

and then

make && make install

result like this:

Installing shared extensions:     /usr/local/php7.1/lib/php/extensions/no-debug-non-zts-20160303/
Installing PHP CLI binary:        /usr/local/php7.1/bin/
Installing PHP CLI man page:      /usr/local/php7.1/php/man/man1/
Installing PHP FPM binary:        /usr/local/php7.1/sbin/
Installing PHP FPM defconfig:     /usr/local/php7.1/etc/
Installing PHP FPM man page:      /usr/local/php7.1/php/man/man8/
Installing PHP FPM status page:   /usr/local/php7.1/php/php/fpm/
Installing phpdbg binary:         /usr/local/php7.1/bin/
Installing phpdbg man page:       /usr/local/php7.1/php/man/man1/
Installing PHP CGI binary:        /usr/local/php7.1/bin/
Installing PHP CGI man page:      /usr/local/php7.1/php/man/man1/
Installing build environment:     /usr/local/php7.1/lib/php/build/
Installing header files:          /usr/local/php7.1/include/php/
Installing helper programs:       /usr/local/php7.1/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php7.1/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php7.1/lib/php/
[PEAR] Archive_Tar    - installed: 1.4.3
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util       - installed: 1.4.2
[PEAR] PEAR           - installed: 1.10.5
Wrote PEAR system config file at: /usr/local/php7.1/etc/pear.conf
You may want to add: /usr/local/php7.1/lib/php to your php.ini include_path
/home/stack/data/php-7.1.21/build/shtool install -c ext/phar/phar.phar /usr/local/php7.1/bin
ln -s -f phar.phar /usr/local/php7.1/bin/phar
Installing PDO headers:           /usr/local/php7.1/include/php/ext/pdo/

5. configure php.ini

try to get php.ini from github
or

cp php.ini-development  /usr/local/php7.1.9/lib/php.ini

6. generate php-fpm.sock

cd /usr/local/php7.1/etc && mv php-fpm.conf.default php-fpm.conf
cd php-fpm.d && mv www.conf.default www.conf

and then use php-fpm.sock by edit configure file

vim www.conf

change

listen = 127.0.0.1:9000

to

;listen = 127.0.0.1:9000
listen = /usr/local/php7.1/sbin/php7.1-fpm.sock

now, we should restart php-fpm to enable configuration

cd /usr/local/php7.1/sbin && mv php-fm php7.1-fpm && ./php7.1-fpm

7. add php7.1 set to environment

cd /usr/local/php7.1/bin && mv php php7.1
ln -s /usr/local/php7.1/bin/php7.1 /usr/bin/php7.1

now, we can use php in command line like

php7.1 -v
发布了136 篇原创文章 · 获赞 94 · 访问量 22万+

猜你喜欢

转载自blog.csdn.net/somehow1002/article/details/85171449
今日推荐