2020-11-26发布了PHP8.0的正式版
介绍下它的安装,并使用laravel对比下PHP7

安装与配置

本次使用的操作系统Ubuntu 18.04.4 LTS

安装

1.准备必要库

apt-get install -y autoconf libxml2-dev libsqlite3-dev \
libcurl4-openssl-dev libssl-dev libonig-dev libtidy-dev zlib1g-dev

2.去官网下载8.0正式版 https://www.php.net/releases/8.0/en.php

3.解压安装

tar php-8.0.0.tar.gz
cd php-8.0.0
./configure --prefix=/opt/php8 --with-config-file-path=/opt/php8/etc \
--enable-fpm --enable-mysqlnd --enable-opcache --enable-pcntl \
--enable-mbstring --enable-soap --enable-zip --enable-calendar \
--enable-bcmath --enable-exif --enable-ftp --enable-intl --with-mysqli \
--with-pdo-mysql --with-openssl --with-curl --with-gd --with-gettext \
--with-mhash --with-openssl --with-mcrypt --with-tidy --enable-wddx \
--with-xmlrpc --with-zlib
make
make install
cp php.ini-production /opt/php/etc/php.ini
cd /opt/php8/etc
cp php-fpm.conf.default php-fpm.conf
cp ./php-fpm.d/www.conf.default ./php-fpm.d/www.conf

4.做个软连接

ln -s /opt/php8/bin/php /usr/bin/php8

4.安装composer

cd /opt/php8/bin/
curl -sS https://getcomposer.org/installer | php8
ln -s /opt/php8/bin/composer.phar /usr/bin/composer8
composer8 config -g repo.packagist composer https://mirrors.aliyun.com/composer/

4.添加一个php8.0的system service

vim /lib/systemd/system/php8.0-fpm.service

内容如下

[Unit]
Description=The PHP 8.0 FastCGI Process Manager
Documentation=man:php-fpm8.0(8)
After=network.target[Service]
Type=simple
PIDFile=/var/run/php8.0-fpm.pid
ExecStart=/opt/php8/sbin/php-fpm --nodaemonize --fpm-config /opt/php8/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID[Install]
WantedBy=multi-user.target

配置

fpm-fpm,php.ini配置

和PHP7一样,注意下用户权限

opcache配置

PHP8多了一个jit配置,如下

[opcache]
zend_extension=opcache.so
opcache.enable=1
opcache.jit_buffer_size=100M
opcache.jit=1255

启动

systemctl start php8.0-fpm

laravel

创建一个laravel项目

cd /opt/web
composer8 create-project --prefer-dist laravel/laravel php8

配置一下.env文件

nginx配置

nginx的配置和PHP7的一致

server {listen 94;access_log  /tmp/test94.log main;root /opt/web/php8/public;index index.php index.html index.htm;location / {try_files $uri $uri/ /index.php?$query_string;}location ~ \.php {fastcgi_pass unix:/run/php/php8.0-fpm.sock;fastcgi_index /index.php;include fastcgi_params;fastcgi_split_path_info       ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO       $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}
}

添加一个接口

laravel7的路由写法在laravel8中有点问题,改下RouteServiceProvider.php的写法。
比如API路由,将$this->namespace改为App\Http\Controllers\Api

public function boot(){$this->configureRateLimiting();$this->routes(function () {Route::prefix('api')->middleware('api')->namespace('App\Http\Controllers\Api')->group(base_path('routes/api.php'));Route::middleware('web')->namespace($this->namespace)->group(base_path('routes/web.php'));});}

其他一样,不用修改。
加个测试接口看看:

Route::get('/test','WxController@test');

test接口查一条数据并返回

<?phpnamespace App\Http\Controllers\Api;use App\Models\WareHouses;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;class WxController extends BaseController
{use AuthorizesRequests, DispatchesJobs, ValidatesRequests;public function test(Request $request){return WareHouses::find(1)->toarray();}
}

对比测试PHP7

本次使用PHP7.3,接口代码和PHP8一致,两者都开启opcache。

服务器配置是1核2G,用ab简单测试下。

ab -n 100 -c 10

PHP7.3的测试结果如下:

This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.10.10 (be patient).....doneServer Software:        nginx/1.14.0
Server Hostname:        192.168.10.10
Server Port:            94Document Path:          /api/test
Document Length:        255 bytesConcurrency Level:      10
Time taken for tests:   0.400 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      5720 bytes
HTML transferred:       2550 bytes
Requests per second:    25.00 [#/sec] (mean)
Time per request:       399.994 [ms] (mean)
Time per request:       39.999 [ms] (mean, across all concurrent requests)
Transfer rate:          13.97 [Kbytes/sec] receivedConnection Times (ms)min  mean[+/-sd] median   max
Connect:        8   10   2.1     11      13
Processing:   101  159  42.8    174     228
Waiting:      101  159  42.8    174     228
Total:        114  170  42.0    186     235Percentage of the requests served within a certain time (ms)50%    18666%    18675%    19780%    21990%    23595%    23598%    23599%    235100%    235 (longest request)

PHP8.0的测试结果如下:

This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.10.10 (be patient).....doneServer Software:        nginx/1.14.0
Server Hostname:        192.168.10.10
Server Port:            94Document Path:          /api/test
Document Length:        255 bytesConcurrency Level:      10
Time taken for tests:   2.441 seconds
Complete requests:      100
Failed requests:        33(Connect: 0, Receive: 0, Length: 33, Exceptions: 0)
Non-2xx responses:      33
Total transferred:      268489 bytes
HTML transferred:       234720 bytes
Requests per second:    40.97 [#/sec] (mean)
Time per request:       244.096 [ms] (mean)
Time per request:       24.410 [ms] (mean, across all concurrent requests)
Transfer rate:          107.42 [Kbytes/sec] receivedConnection Times (ms)min  mean[+/-sd] median   max
Connect:        7   15  18.1     10     132
Processing:    47  210 224.4    106     817
Waiting:       17  118 107.4    101     787
Total:         55  226 222.1    122     828Percentage of the requests served within a certain time (ms)50%    12266%    13775%    16480%    28990%    64095%    80998%    82099%    828100%    828 (longest request)

PHP8.0正式版的编译安装与使用相关推荐

  1. Silverlight3.0正式版(Silverlight3_Tools)离线安装手记

    1.从微软的网站下载Silverlight3_Tools.exe 2.执行Silverlight3_Tools.exe 3.像Silverlight2_Tools一样,Silverlight3_Too ...

  2. Axure RP 8.0正式版下载地址 安装和汉化说明

    1.Axure RP和中文包包下载地址 官网地址:http://www.axure.com.cn/3510/ 2.下载完成后安装 3.破解 axure8.0注册码 激活码:(亲测可用) 用户名:aaa ...

  3. cupy 安装_资源 | 神经网络框架Chainer发布2.0正式版:CuPy独立

    原标题:资源 | 神经网络框架Chainer发布2.0正式版:CuPy独立 选自GitHub 机器之心编译 参与:李泽南.吴攀 Chainer 是一个灵活的神经网络框架,它的一个主要目标就是展现灵活性 ...

  4. php8正式版发布,PHP 8.0 正式版发布,性能提升 10%

    11月27日消息恰逢一年一度感恩节,PHP 8.0 正式版现已正式开放下载. PHP 8.0 引入了 JIT编译器特性,同时加入多种新的语言功能,例如命名参数.联合类型.注解.Constructor ...

  5. Axure 7.0 正式版 + 汉化包 安装

    Axure 7.0 正式版 + 汉化包 安装 详情如下: Axure 7.0 正式版终于发布了,现在提供简体中文版给大家使用. Axure 7.0 正式版: 链接: http://pan.baidu. ...

  6. VMware Workstation v8.0正式版下载+安装+完美汉化补丁+虚拟win8教程

    微软发布Windows 8 Developer Preview(开发预览版)的同时,著名的虚拟机开发商 VMware公司发布了 VMware Workstation v8.0 正式版,对windows ...

  7. 如何在 Mac 和虚拟机上安装 macOS Big Sur 11.0 正式版

    作者主页:www.sysin.org 请访问原文链接:https://sysin.org/blog/how-to-install-macos-big-sur/,查看最新版.转载请保留原文链接. 本文适 ...

  8. linux火狐浏览器49.0安装教程,火狐浏览器v49.0.0 正式版以及长期版本(转载)

    火狐浏览器Mozilla Firefox现已更新至 v49.0 正式版,新版为GNU/Linux平台整合了GTK3,改善了JIT编译器的安全性,并将无加密传输的密码文本框标记为不安全,以提醒用户小 心 ...

  9. linux安装wine教程,Debian,Ubuntu和Linux Mint 上安装 Wine 3.0 正式版

    Wine是一个开放源代码,免费且易于使用的程序,使Linux用户能够在类Unix操作系统上运行一些基于Windows的应用程序. Wine是用于安装几乎所有Windows程序版本的兼容层. 本文介绍了 ...

  10. cocos2d-x 3.0正式版创建project笔记

    cocos2d-x 3.0正式版创建project笔记 不知道Beta版那个高大上的对话框哪里去鸟,正式版又回归到命令行,不知道触碰如此频繁的玩弄追随者的编程习惯是出于什么心理,假设不是为了这个跨平台 ...

最新文章

  1. 对异步脉冲信号的处理——不归0翻转电路
  2. Arch Linux 安装记(安装到移动硬盘)
  3. 怎么发一篇IEEE文章呢?
  4. java8 多个字段分组_MySQL基础之分组查询
  5. phpcms_v9推送到其他栏目后再在其他栏目删除导致数据库出错
  6. strcmp()字符串比较函数
  7. android qq空间 sdk,Android中使用腾讯的SDK完成分享图文到qq空间
  8. 谁说SELINUX,IPTABLES,SAMBA不能共存?
  9. 计算机科学之父图灵的一生
  10. 计算机应用发邮件,使用 SMTP 发送电子邮件
  11. python 三角函数计算
  12. 蓝牙协议(bluetooth spec)
  13. 通过检查table_locks_waited和table_locks_immediate状态变量来分析系统上的表锁定争夺
  14. ESP8266基于MicroPython的TCP socket回调函数实现案例
  15. 七夕了,男朋友说他想学学算法~
  16. jquery展开收起(手风琴)
  17. 一文带您读懂FCC、CE、CCC认证的区别
  18. Python+selenium点击网页上指定坐标
  19. 抛弃flex执念:利用border-collapse实现顺序展示的快速方法
  20. matlab中m文件的好处,请教matlab中M文件问题?

热门文章

  1. ffmpeg 合并音视频命令
  2. IMDB 电影评论情感分类数据集
  3. ZeroMQ XPub/XSub模式
  4. ActiveMQ 反序列化漏洞 (CVE-2015-5254) 漏洞复现
  5. Oracle RAC集群增加新共享硬盘并使用AFD的式增加新ASM磁盘组
  6. java 实验室管理系统_java实验室设备管理系统
  7. [日更-2019.4.20、21] cm-14.1 Android系统启动过程分析(二)-Zygote进程启动过程
  8. 李迟2022年4月工作生活总结
  9. 决定成功十种积极心态,成功有道理
  10. 冻结Excel表格中前两行不滚动问题