首页 > 代码库 > 编译安装php

编译安装php

想要编译安装PHP首先需要安装对应的编译工具。 Ubuntu上使用如下命令安装编译工具和依赖包:

sudo apt-get install build-essential gcc g++ autoconf libiconv-hook-dev libmcrypt-dev libxml2-dev libmysqlclient-dev libcurl4-openssl-dev libjpeg8-dev libpng12-dev libfreetype6-dev \

wget http://php.net/get/php-5.6.30.tar.gz

tar -zxvf php-5.6.30

cd php-5.6.30

./configure   --prefix=/usr   --sysconfdir=/etc   --with-config-file-path=/etc   --without-pear   --enable-fpm   --with-fpm-user=www-data    --with-fpm-group=www-data    --enable-opcache  --enable-mbstring    --enable-mbregex  --without-pdo-sqlite   --with-mysql-sock=/var/run/mysqld/mysqld.sock    --with-mysql=mysqlnd    --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl   --with-curl  --with-zlib   --enable-zip    --with-gd   --with-freetype-dir    --with-jpeg-dir  --with-png-dir  --with-mcrypt    --enable-sockets    -with-xmlrpc     --enable-soap  

make && make install

cp php.ini-production /etc/php.ini

#设置php-fpm系统启动加载项
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
update-rc.d php-fpm defaults

#拷贝php-fpm.conf
cp /etc/php-fpm.conf.default /etc/php-fpm.conf

编译安装php