ubuntu编译安装php7

时间:2020-08-04 14:08:32   收藏:0   阅读:104

一、安装依赖

root@ubuntu1:/tmp# apt-get update

root@ubuntu1:/tmp# apt install gcc

root@ubuntu1:/tmp# apt install make

root@ubuntu1:/tmp# apt install openssl

root@ubuntu1:/tmp# apt install curl

root@ubuntu1:/tmp# apt install libbz2-dev

root@ubuntu1:/tmp# apt install libxml2-dev

root@ubuntu1:/tmp# apt install libjpeg-dev

root@ubuntu1:/tmp# apt install libpng-dev

root@ubuntu1:/tmp# apt install libfreetype6-dev

root@ubuntu1:/tmp# apt install libzip-dev

root@ubuntu1:/tmp# apt install libssl-dev

 

二、下载php包

root@ubuntu1:/tmp# wget http://am1.php.net/distributions/php-7.2.12.tar.gz

root@ubuntu1:/tmp# tar -zxvf php-7.2.12.tar.gz

root@ubuntu1:/tmp# cd php-7.2.12/

 

三、安装

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl-dir=/usr/bin/curl --enable-mbregex --enable-mbstring --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts

make

make install

 

四、配置

cp php.ini-development /usr/local/php/etc/php.ini

cd /usr/local/etc/

cp php-fpm.conf.default php-fpm.conf

cd php-fpm.d

cp www.conf.default www.conf

groupadd www
useradd -g www www

 

五、启动php-fpm

/usr/local/php/sbin/php-fpm

 

六、设置PHP执行命令

1.vim /etc/profile

在最后加入以下内容

PATH=$PATH:/usr/local/php/bin
export PATH

2.执行以下命令:

source /etc/profile

php -v

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!