Ubuntu编译安装PHP7.0.0

编译环境

sudo apt-get install build-essential

xml

sudo apt-get install libxml2-dev

pcre

sudo apt-get install libpcre3-dev

jpeg

sudo apt-get install libjpeg62-dev

freetype

sudo apt-get install libfreetype6-dev

png

sudo apt-get install libpng12-dev libpng3 libpnglite-dev

iconv

sudo apt-get install libiconv-hook-dev libiconv-hook1

mycrypt

sudo apt-get install libmcrypt-dev libmcrypt4

mhash

sudo apt-get install libmhash-dev libmhash2

openssl

sudo apt-get install libltdl-dev libssl-dev
apt-get -y install libcurl3-openssl-dev

curl

sudo apt-get install libcurl4-openssl-dev

mysql

sudo apt-get install libmysqlclient-dev

imagick

sudo apt-get install libmagickcore-dev libmagickwand-dev

ubuntu 无法找到 iconv

sudo ln -s /usr/lib/libiconv_hook.so.1.0.0 /usr/lib/libiconv.so
sudo ln -s /usr/lib/libiconv_hook.so.1.0.0 /usr/lib/libiconv.so.1

安装PHP扩展

sudo apt-get install autoconf automake m4

./configure –prefix=/usr/local/php7 \
–with-config-file-path=/etc/php7 \
–with-mcrypt=/usr/include \
–with-mysql=mysqlnd \
–with-mysqli=mysqlnd \
–with-pdo-mysql=mysqlnd \
–with-gd \
–with-iconv \
–with-zlib \
–enable-xml \
–enable-bcmath \
–enable-shmop \
–enable-sysvsem \
–enable-inline-optimization \
–enable-mbregex \
–enable-fpm \
–enable-mbstring \
–enable-ftp \
–enable-gd-native-ttf \
–with-openssl \
–enable-pcntl \
–enable-sockets \
–with-xmlrpc \
–enable-zip \
–enable-soap \
–without-pear \
–with-gettext \
–enable-session \
–with-curl \
–with-jpeg-dir \
–with-freetype-dir \
–enable-opcache

make install
安装目录如下
nstalling shared extensions: /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/
Installing PHP CLI binary: /usr/local/php7/bin/
Installing PHP CLI man page: /usr/local/php7/php/man/man1/
Installing PHP FPM binary: /usr/local/php7/sbin/
Installing PHP FPM config: /usr/local/php7/etc/
Installing PHP FPM man page: /usr/local/php7/php/man/man8/
Installing PHP FPM status page: /usr/local/php7/php/php/fpm/
Installing phpdbg binary: /usr/local/php7/bin/
Installing phpdbg man page: /usr/local/php7/php/man/man1/
Installing PHP CGI binary: /usr/local/php7/bin/
Installing PHP CGI man page: /usr/local/php7/php/man/man1/
Installing build environment: /usr/local/php7/lib/php/build/
Installing header files: /usr/local/php7/include/php/
Installing helper programs: /usr/local/php7/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php7/php/man/man1/
page: phpize.1
page: php-config.1
/root/php-7.0.0/build/shtool install -c ext/phar/phar.phar /usr/local/php7/bin
ln -s -f phar.phar /usr/local/php7/bin/phar
Installing PDO headers: /usr/local/php7/include/php/ext/pdo/

配置php7-fpm
cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm
chmod +x /etc/init.d/php7-fpm
vim /etc/init.d/php7-fpm

停掉之前的php5-fpm
/etc/init.d/php5-fpm stop

修正php7-fpm配置文件
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf

开启pid和errorlog

cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf

修改 www.conf

修改里面的用户,nobody -> www-data

listen.owner = www-data
listen.group = www-data
listen = /var/run/php7-fpm.sock
;listen = 127.0.0.1:9000

启动
/etc/init.d/php7-fpm start

修改/var/run/php7-fpm.sock权限
chown www-data:www-data /var/run/php7-fpm.sock

修改nginx配置文件
fastcgi_pass unix:/var/run/php7-fpm.sock;

/usr/local/php7/bin/php7-fpm -v

建立php.ini

mkdir /etc/php7/
cp /root/php-7.0.0/php.ini-development /etc/php7/
mv /etc/php7/php.ini-development /etc/php7/php.ini

发表评论

邮箱地址不会被公开。 必填项已用*标注