在Ubuntu14.04上将PHP升级到7.0.0

背景说明

因为项目原因,不得不使用Ubuntu比较旧的版本14.04。导致在搭建Gerrit和dokuwiki时,因为想用尽可能新的版本,而新版本对PHP版本也有要求。
在Ubuntu14.04上,透过以下方式仍无法获取到PHP 5.6及更高版本

sudo apt-get install software-properties-common
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

下载源码编译

1. 下载

https://www.php.net/releases/
https://www.php.net/distributions/php-7.0.0.tar.gz

2. 解压,并安装依赖包

tar zxvf php-7.0.0.tar.gz
sudo apt-get install -y libxml2-dev sqlite3 libsqlite3-dev libcurl4-gnutls-dev libjpeg-dev libmcrypt-dev libreadline6 libreadline6-dev libssl-dev libpng-dev libfreetype6-dev 

3. 编译

cd php-7.0.0/
./configure
./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 --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts
./configure --prefix=/usr/local/php --enable-fpm --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --with-mysqli --with-mysql-sock --enable-pdo --with-pdo-mysql --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear --with-libdir=/lib/x86_64-linux-gnu --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --enable-xml

make -j32
make test -j32
sudo make install​

4. 配置

sudo cp php.ini-development /usr/local/php/lib/php.ini
cd /usr/local/php/etc/
sudo cp php-fpm.conf.default php-fpm.conf
cd /usr/local/php/etc/php-fpm.d
sudo cp www.conf.default www.conf
sudo vim www.conf
user = www-data
group = www-data

;listen = 127.0.0.1:9000
listen = /var/run/php-fpm.sock

listen.owner = www-data
listen.group = www-data

配置PATH环境变量

sudo vi /etc/profile.d/xxx.sh
export PATH=$PATH:/usr/local/php/bin

5. 启动

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

配置开机启动

sudo vi /etc/rc.local
/usr/local/php/sbin/php-fpm

5. 验证

php --version
PHP 7.0.0 (cli) (built: Apr 14 2021 20:12:34) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值