ning

一生太短,一瞬好长

0%

  • 解决brew安装的PHP报错
    1
    2
    3
    4
    5
    6
    Cannot load Zend OPcache - it was built with configuration API220131226,NTS, whereas running engine is API220131226,NTS,debug
    PHP Warning: PHP Startup: igbinary: Unable to initialize module
    Module compiled with build ID=API20131226,NTS
    PHP compiled with build ID=API20131226,NTS,debug
    These options need to match
    in Unknown on line 0
  • 解决办法
    原因是因为编译的方式不同,导致不一致,所以导致不能加载,这里提醒,一般情况下使用brew直接安装上扩展,这样就不会报错了
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    # 来源github brew issue
    I loaded up a fresh copy of OS X 10.10 and do not have this problem. If you have a non-bottled version of PHP, then you may be seeing the clash with the bottled version of php56-opcache. I think one of the following options will work:

    Skip the bottle for php56-opcache (I don't recommend this long-term, see below):

    brew install --build-from-source php56-opcache
    It would be preferable to use the bottled version of PHP 5.6 so you can use bottles from future formulas and save compile time. Here's how you can transition:
    (export ALLPHP56=$(brew list | grep -E '^php56') ; brew uninstall --force $ALLPHP56 ; brew insta
    //或者直接也是可以的
    brew reinstall --build-from-source php56-opcache

昨天使用laravel使用 [mewebstudio/captcha]url(https://github.com/mewebstudio/captcha) 验证码扩展的时候出现了imagettfbbox()不存在的异常,去网上搜索了一下,是因为osx10.12系统的php5.6gd库并没有编译完全,那么这边的方案是直接用homebrew替代.那么关于[homebrew]url(https://brew.sh/index_zh-cn.html)的安装的这边就不赘述了,
官网有中文教程,当然在使用的时候记得开启翻墙,这样会访问的很快。

1
2
#搜索php版本
brew search php56

图1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#安装php56,下面是可加参数
###
--with-cgi
Enable building of the CGI executable (implies --without-fpm)
--with-debug
Compile with debugging symbols
--with-enchant
Build with enchant support
--with-gmp
Build with gmp support
--with-homebrew-curl
Include Curl support via Homebrew
--with-homebrew-libressl
Include LibreSSL instead of OpenSSL via Homebrew
--with-homebrew-libxml2
Include Libxml2 support via Homebrew
--with-homebrew-libxslt
Include LibXSLT support via Homebrew
--with-httpd22
Enable building of shared Apache 2.2 Handler module
--with-httpd24
Enable building of shared Apache 2.4 Handler module
--with-imap
Include IMAP extension
--with-libmysql
Include (old-style) libmysql support instead of mysqlnd
--with-mssql
Include MSSQL-DB support
--with-pdo-oci
Include Oracle databases (requries ORACLE_HOME be set)
--with-pear
Build with PEAR
--with-phpdbg
Enable building of the phpdbg SAPI executable
--with-postgresql
Build with postgresql support
--with-thread-safety
Build with thread safety
--without-bz2
Build without bz2 support
--without-fpm
Disable building of the fpm SAPI executable
--without-ldap
Build without LDAP support
--without-legacy-mysql
Do not include the deprecated mysql_ functions
--without-mysql
Remove MySQL/MariaDB support
--without-pcntl
Build without Process Control support
--without-unixodbc
Build without unixODBC support
--HEAD
Install HEAD version
###
#执行命令,这边直接可以在后面加参数
这边是直接加上apache参数(提示这里用osx10.12的apache时也要安装),会有 libexec.so直接生成
如果你不想 下图有下载链接 你可以直接下载
brew install php56 --with httpd24

libexec下载链接:
[libexec]url(http://cdn.ningke.xin/libexec.zip)
让默认的apache使用brew安装的php扩展,下载上面的libexec 放在 /usr/local/Cellar/php56/5.6.30_6/libexec目录下,当然您也可以放在别的目录。

1
2
3
4
5
6
7
8
9
cp -r libexec /usr/local/Cellar/php56/5.6.30_6/libexec
#编辑apache配置文件
sudo vim /etc/apache2/httpd.conf
#找到170行左右位置 注释掉下行(前面加上#)
#LoadModule php5_module libexec/apache2/libphp5.so
#在下面新增一行加入
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
#重启apache
sudo apachectl restart

访问phpinfo文件看是否切换成功,如果出现下图界面说明成功切换
phpinfo

安装之后切换php版本,会看到如下提示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#按照如下提示,执行下行命令,在执行php -v 就变成brew安装的php5.6版本了
export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"

###提示
If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc,
~/.zshrc, ~/.profile or your shell's equivalent configuration file:

export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"

✩✩✩✩ FPM ✩✩✩✩

To launch php-fpm on startup:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

The control script is located at /usr/local/opt/php56/sbin/php56-fpm

OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:

PATH="/usr/local/sbin:$PATH"

You may also need to edit the plist to use the correct "UserName".

Please note that the plist was called 'homebrew-php.josegonzalez.php56.plist' in old versions
of this formula.

With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system
you have to install php with the --with-httpd24 option. See brew options php56 for more details.

To have launchd start homebrew/php/php56 now and restart at login:
brew services start homebrew/php/php56

另外,brew安装其他扩展的时候,比如php56-opcache php56-mcrypt等 要注意下,一定要加上 –build-from-source不然的话会出现 :

1
2
3
4
5
6
7
8
9
10
11
12
#执行 php -v 可能出现以下提示,是因为brew编译的扩展和php官网扩展不一致导致的。
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php56-mcrypt/mcrypt.so' - dlopen(/usr/local/opt/php56-mcrypt/mcrypt.so, 9): Library not loaded: /usr/local/opt/libtool/lib/libltdl.7.dylib
Referenced from: /usr/local/opt/php56-mcrypt/mcrypt.so
Reason: image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php56-mcrypt/mcrypt.so' - dlopen(/usr/local/opt/php56-mcrypt/mcrypt.so, 9): Library not loaded: /usr/local/opt/libtool/lib/libltdl.7.dylib
Referenced from: /usr/local/opt/php56-mcrypt/mcrypt.so
Reason: image not found in Unknown on line 0
PHP 5.6.30 (cli) (built: Mar 11 2017 09:56:27)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

解决办法,如果已经出现了运行以下命令(例子),执行之后再运行php -v就不会出现以上提示了

1
2
brew reinstall php56-opcache ---build-from-source
brew reinstall php56-mcrypt ---build-from-source

首先必须关闭自带的防火墙(firewall不管肯定会出现问题)
一.第二点很重要的就是必须升级内核一下介绍升级内核方法。

1
sudo systemctl stop firewalld.service

导入key
如果你修改了repo的gpgcheck=0也可以不导入key

1
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

2、安装elrepo的yum源

1
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

在yum的ELRepo源中,有最新版本内核、安装内核

1
yum --enablerepo=elrepo-kernel install  kernel-ml-devel kernel-ml -y

查看默认启动顺序

1
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg

4会出现一下界面,你会看到你的内核版本列表,4.7版本的内核在第一个也就是第0个,进行如下设置,并且重启使内核生效

1
grub2-set-default 0 reboot

5.重启之后,使用如下命令你会看到你的内核已经变成4.7了

1
uname -r