我可以在 PHP 框架的 Lithium 中使用 APCu 而无需配置,还是应该更改代码?
Can I use APCu in Lithium of the PHP Framework with no configuration, or should I change the code?
当我设置一个锂项目(下面的过程)并启动 PHP 网络服务器时,我在框架的欢迎页面上得到了 Apc 禁用(Apc ✗)的信息。
但我 运行 sed -ir "s/'apc'/'apcu'/" libraries/lithium/storage/cache/adapter/Apc.php
,然后我启用了 Apc (Apc ✓)。
此代码更改是否正确?还是不?
环境
- 软呢帽 26 (x86_64)
- PHP 7.1.7 (cli)(内置:2017 年 7 月 6 日 12:10:54)(NTS)
- php-pecl-apcu 5.1.8
- Composer 版本 1.4.2 2017-05-17 08:17:52
详情:
$ rpm -qa | grep php
php-pdo-7.1.7-1.fc26.x86_64
php-pecl-apcu-devel-5.1.8-2.fc26.x86_64
php-7.1.7-1.fc26.x86_64
php-mysqlnd-7.1.7-1.fc26.x86_64
php-json-7.1.7-1.fc26.x86_64
php-devel-7.1.7-1.fc26.x86_64
php-cli-7.1.7-1.fc26.x86_64
php-pecl-apcu-5.1.8-2.fc26.x86_64
php-common-7.1.7-1.fc26.x86_64
如何设置 Lithium,以及如何访问框架的欢迎页面:
$ composer.phar create-project --prefer-dist unionofrad/framework app
Installing unionofrad/framework (v1.1.1)
- Installing unionofrad/framework (v1.1.1): Loading from cache
Created project in app
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
- Installing composer/installers (v1.3.0): Loading from cache
- Installing unionofrad/lithium (v1.1.0): Loading from cache
Writing lock file
Generating autoload files
$ cd app/
$ php -S 0.0.0.0:8080 -t app/webroot index.php
设置差异
.orig文件为备份
/etc/php.ini:
$ diff /etc/php.ini.orig /etc/php.ini
460c460,461
< error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
---
> ;error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
> error_reporting = E_ALL
/etc/php.d/40-apcu.ini:
$ diff /etc/php.d/40-apcu.ini.orig /etc/php.d/40-apcu.ini
9a10
> apc.enable_cli=1
案例
带有 -c /etc/php.ini
参数
运行带参数,但是没有效果,:
$ php -c /etc/php.ini -S 0.0.0.0:8080 -t app/webroot index.php
显示 Apc 禁用 (Apc ✗)。
通过 dnf 安装 php-pecl-apcu-bc
包使适应 Apc ✓。但是php-pecl-apcu-bc
是"APCu Backwards Compatibility Module"……哦。
安装前:
$ php -m
[PHP Modules]
apcu
bz2
calendar
Core
ctype
curl
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
sockets
SPL
sqlite3
standard
tokenizer
zlib
[Zend Modules]
安装后:
$ php -m
[PHP Modules]
apc
apcu
bz2
calendar
Core
ctype
curl
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
sockets
SPL
sqlite3
standard
tokenizer
zlib
[Zend Modules]
当我设置一个锂项目(下面的过程)并启动 PHP 网络服务器时,我在框架的欢迎页面上得到了 Apc 禁用(Apc ✗)的信息。
但我 运行 sed -ir "s/'apc'/'apcu'/" libraries/lithium/storage/cache/adapter/Apc.php
,然后我启用了 Apc (Apc ✓)。
此代码更改是否正确?还是不?
环境
- 软呢帽 26 (x86_64)
- PHP 7.1.7 (cli)(内置:2017 年 7 月 6 日 12:10:54)(NTS)
- php-pecl-apcu 5.1.8
- Composer 版本 1.4.2 2017-05-17 08:17:52
详情:
$ rpm -qa | grep php
php-pdo-7.1.7-1.fc26.x86_64
php-pecl-apcu-devel-5.1.8-2.fc26.x86_64
php-7.1.7-1.fc26.x86_64
php-mysqlnd-7.1.7-1.fc26.x86_64
php-json-7.1.7-1.fc26.x86_64
php-devel-7.1.7-1.fc26.x86_64
php-cli-7.1.7-1.fc26.x86_64
php-pecl-apcu-5.1.8-2.fc26.x86_64
php-common-7.1.7-1.fc26.x86_64
如何设置 Lithium,以及如何访问框架的欢迎页面:
$ composer.phar create-project --prefer-dist unionofrad/framework app
Installing unionofrad/framework (v1.1.1)
- Installing unionofrad/framework (v1.1.1): Loading from cache
Created project in app
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
- Installing composer/installers (v1.3.0): Loading from cache
- Installing unionofrad/lithium (v1.1.0): Loading from cache
Writing lock file
Generating autoload files
$ cd app/
$ php -S 0.0.0.0:8080 -t app/webroot index.php
设置差异
.orig文件为备份
/etc/php.ini:
$ diff /etc/php.ini.orig /etc/php.ini 460c460,461 < error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT --- > ;error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT > error_reporting = E_ALL
/etc/php.d/40-apcu.ini:
$ diff /etc/php.d/40-apcu.ini.orig /etc/php.d/40-apcu.ini 9a10 > apc.enable_cli=1
案例
带有 -c /etc/php.ini
参数
运行带参数,但是没有效果,:
$ php -c /etc/php.ini -S 0.0.0.0:8080 -t app/webroot index.php
显示 Apc 禁用 (Apc ✗)。
通过 dnf 安装 php-pecl-apcu-bc
包使适应 Apc ✓。但是php-pecl-apcu-bc
是"APCu Backwards Compatibility Module"……哦。
安装前:
$ php -m
[PHP Modules]
apcu
bz2
calendar
Core
ctype
curl
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
sockets
SPL
sqlite3
standard
tokenizer
zlib
[Zend Modules]
安装后:
$ php -m
[PHP Modules]
apc
apcu
bz2
calendar
Core
ctype
curl
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
sockets
SPL
sqlite3
standard
tokenizer
zlib
[Zend Modules]