0%

GStreamer在mac上的安装

GStreamer 是一个基于流水线的多媒体框架,基于GObject,以C语言写成。凭借GStreamer,程序员可以很容易地创建各种多媒体功能组件,包括简单的音频回放,音频和视频播放,录音,流媒体和音频编辑。基于流水线设计,可以创建诸如视频编辑器、流媒体广播和媒体播放器等等的很多多媒体应用。

Mac安装

推荐使用Homebrew安装

1
brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly

官网下载pkg包安装比较复杂还需要自己去安装很多依赖和插件这里推荐使用Homebrew安装。

同样linux下同样推荐使用包管理工具安装。自己编译安装需要很长时间。而且容易出现依赖问题可能会出错。

我只在Ubuntu上测试过自己编译安装,mac上没有测试过。

安装完成后终端输入gst-launch-1.0 --version。如果出现版本信息后说明安装成功。

linux上安装

和mac上安装类似,安装命令:

1
apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools

GStreamer资料

一键生成AppIcon脚本(改进版)

看到了一篇文章是一个脚本用来生成AppIcon,这篇文章的作者用的是swift写的。然后我就把我之前写的一个自己用的shell脚本优化了下。
一键生成AppIcon的shell脚本.

使用方法

准备的东西:

  • 一键生成AppIcon的脚本
  • 分辨率高于1024x1024的图片(以为在iOS 11以后需要一张1024的图片用在App Store中)

首先下载脚本到本地,然后把脚本和图片放到一个文件夹下。然后确认脚本是否有执行权限。

没有权限的脚本,执行的时候会报错permission denied:这时候要给脚本加上执行权限,命令是chmod +x ios_icon_shell_sips.sh。这样就给脚本加上了执行权限。(这边有关文件权限的问题可以自己去查看有关linux文件权限的东西。)

下面的图就是有执行权限的脚本

在终端中执行这个脚本./ios_icon_shell_sips.sh

然后输入图片名:

可以看到输入的图片为test.png,然后你可以看到这样土拍你的信息,然后输入你要生成哪里用的图标。可以选择iPhone、iPad、Apple Watch、macOS。目前暂时不支持AppleTV。(我这里的图片的分辨率是512x512。这样生成的1024x1024的图片可能会出现不清楚的情况,最好还是用大于1024的图片)

然后输入你想要生成的设备对应的编号。(可以多次输入,会多次生成)

生成结束后,输入q可以退出。

这样生成的图标就按照固定的格式和命名生成在了当前的文件夹下。

脚本分析

首先说一下之前的那个脚本,那个脚本很简单,只需要在执行的时候接受一个图片参数就可以,只能满足基本要求,不够灵活。

技术难点:

  • 键盘输入交互
  • 生成图标

接受键盘输入:这里使用的是read来监听键盘输入。使用do while循环。具体的逻辑看下脚本内容会很清楚。

遇到的问题是监听键盘的时候,当什么都不输入的情况下直接回车。会出现错误。错误的原因是逻辑运算的问题。因为我这里要比较输入的参数所以这里会报错$aNum = 1。(这里的aNum就是你输入的设备参数。如果你这时候没有输入直接回车会出现 = 1的比较所以会报错。使用"$aNum" = 1加上双引号就不会出现这样的情况。因为不会出现一个空值,只会是一个空字符串。)具体的东西可以去参考shell的语法。

生成图标:这里使用的是macOS系统中自带的图片处理命令sips
详细的使用说明可以参考 man sips

这里只用到了改变大小和获取图片mete信息的功能。

改变大小: sips -z 512 512 $Pic --out Mac512@1x.png
获取图片信息:sips -g all $Pic

图片处理框架还要其他可以选择。macOS下比较好用的就是这个sips。可以通过这个命令完成很多东西。比如一些图片的批处理操作。当然也可以安装其他图片处理库。这里我还在linux上用过ImageMagick
可以参考另一篇文章

shell脚本一键生成icon

realm安装与编译踩坑

realm是一个简单易用的跨平台数据库

我这里用的是iOS版本,所以这里的问题只针对于iOS的版本。

安装

文档中有安装步骤,根据文档中的教程去安装即可。

CocoaPods方式

在podfile文件中添加pod 'Realm',然后执行pod install国内用户可能会出现下面的错误。

1
Downloading core failed. Please try again once you have an Internet connection..

出错的原因是因为被墙了,这时候你需要一个VPN,然后重新执行pod install就可以了。没有VPN的话使用静态库的方式去安装就可以。

静态库的安装

下载你想要安装的版本。

下载地址

下载之后解压,把ios/static/目录下的Realm.framework推进项目中。然后在Build Phases下的. Link Binary with Libraries中添加libc++.tbdlibz.tbd,然后编译。

踩坑

第一问题就是被墙问题。解决办法就是翻墙使用VPN或者采用另一种办法。

还有一个是升级编译报错问题。我这里升级realm到最新版,然后编译报错。而且还有很多警告。下面是其中一个警告

1
2
3
ld: warning: object file (/Users/abai/Library/Developer/Xcode/DerivedData/Diary-dadfyxaqgthxebftmnqlhyfwcfpv/Build/Products/Debug-iphoneos/libRealm.a(collection_change_builder.o)) was built for newer iOS version (10.1) than being linked (9.0)

"realm::sync::make_sync_history(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:

这里发现问题应该出在了这个派生文件。所以删除掉/Users/abai/Library/Developer/Xcode/DerivedData/下面关于我这个项目的文件。然后重新编译,正常运行。

iOS删除DerivedData和Archives

DerivedData文件夹下包含项目的所有中间构建信息,debug版本和release版本的的build target(构建目标)。(项目索引、build输出以及日志)。当你遇到索引问题是(编译错误、重复索引、或者编译缓慢的问题的话)删除对应的项目的文件夹后,然后重新编译会有作用。

Archives文件夹中包含目标的归档形式。也就是发布版本以及dSYM数据供以后调试,如果您希望能够调试应用程序的部署版本,那么您不应该删除它。这里建议不删除这个文件夹中的内容。

关于如何清理空间参考下面前两篇中文的资料。

如何正确删除derivedData文件夹和Archives文件,参考下面3、4两篇文章。

参考文件:

Evernote使用Markdown(2017年08月)

Evernote支持Markdown了?不,这是一个笑话。曾经出现了很多次新闻说官方要支持Markdown,但是最后都没了消息。尝试了很多种方案。从使用体验来说,目前认为最好的方案是马克飞象,但是马克飞象是单向的,他生成的笔记只能通过马克飞象去编辑同步,而且比较局限,想要单独保留md文件还要单独去复制保存。而且目前是订阅收费79一年。我的会员到期了,所以找了找替代方案。

Sublime Text

配合插件MarkdownEditing编写markdown很方便。但是同步到印象笔记我这里有问题。而且我没有找到很好的预览方式。我习惯的预览方式是左右两栏、能实时预览。然后试了下之后放弃了。可能有更好的插件方案与使用方案。

Atom

Atom配合插件ever-notedown一直有错误,不知道是不是配置有错误。不过Atom的主题感觉很好看渲染出来的效果也很好看。单纯的做一个Markdown的编辑器的话还是可以的。

Uncaught TypeError: Cannot read property ‘addnote’ of null

Visual Studio Code

Visual Studio Code 配合evermonkey插件目前能够满足我现在的需求,

evermonkey-github

evermonkey官网

文档比较详细,可以直接查看文档,安装和使用。

踩坑指南

安装:直接搜索并安装

配置:填好账号信息

关于Visual Studio Code中控制字符问题

publish的过程中遇到问题:

参考我和作者的交流:

Evernote Error: 11

参考知乎上我的的一个回答:

Mac 上的 VSCode 编写 Markdown 总是出现隐藏字符?

总结一下,感觉这里的问题全是Visual Studio Code的控制字符的问题。

首先说明一种肯定会产生退格字符的情况:

输入中文的情况下,输入一个或者多个字母后,不要点空格选择汉字,点击退格删除按钮,等删除到只剩一个字母时候会出现一个退格键,同样的操作在其他编辑器上不会出现,这里我怀疑是设置问题(目前2017年08月08日还没有找到解决办法)。

解决:

首先要能看到退格符,测试发现在Sublime中可以显示退格符,在Atom、Visual Studio Code中都不显示以及在好多IDE中都不显示,后来查到Visual Studio Code后来支持显示控制字符了。所以是设置问题。

添加下面的配置后Visual Studio Code成功显示了控制字符,但是这样并不能根本解决问题。目前我也不知道这些控制字符怎么产生的。

开源项目支持CocoaPods

CocoaPods可以方便的管理你使用的第三方框架,这里讲解下怎么让你的项目支持CocoaPods。

这里使用ZCWDropDownMenu这个项目做例子,从头说明

Github上创建项目

首先要在Github上创建项目ZCWDropDownMenu,然后把自己的项目push上去。具体步骤这里不做详细介绍。

本地操作

首先在终端下进到项目目录

cd ZCWDropDownMenu/

创建podspec文件

pod spec create ZCWDropDownMenu

创建完成后会创建一个通用的podspec文件,我们只需要去修改下其中的内容就可以。

编辑修改podspec文件

vim ZCWDropDownMenu.podspec

我们可以根据里面的注释去修改。

下面是自动创建的模板,包括了所以详细信息,后面会弄一个简单版本。(可以参考下其他优秀开源框架的中的podspec文件)

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#
# Be sure to run `pod spec lint ZCWDropDownMenu.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#

Pod::Spec.new do |s|

# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# These will help people to find your library, and whilst it
# can feel like a chore to fill in it's definitely to your advantage. The
# summary should be tweet-length, and the description more in depth.
#
# 项目名
s.name = "ZCWDropDownMenu"
# 项目版本
s.version = "0.0.3"
# 项目简单描述
s.summary = "Drop-down Menu"

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = 'Drop-down Menu 下拉菜单'

s.homepage = "https://github.com/zcwlwen/ZCWDropDownMenu"
# s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"


# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Licensing your code is important. See http://choosealicense.com for more info.
# CocoaPods will detect a license file if there is a named LICENSE*
# Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
#

s.license = "MIT"
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }


# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the authors of the library, with email addresses. Email addresses
# of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
# accepts just a name if you'd rather not provide an email address.
#
# Specify a social_media_url where others can refer to, for example a twitter
# profile URL.
#

s.author = { "zcw" => "zcw_lwen@sina.cn" }
# Or just: s.author = "zcw"
# s.authors = { "zcw" => "zcw_lwen@sina.cn" }
# s.social_media_url = "http://twitter.com/zcw"

# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If this Pod runs only on iOS or OS X, then specify the platform and
# the deployment target. You can optionally include the target after the platform.
#

s.platform = :ios
# s.platform = :ios, "5.0"

# When using multiple platforms
# s.ios.deployment_target = "5.0"
# s.osx.deployment_target = "10.7"
# s.watchos.deployment_target = "2.0"
# s.tvos.deployment_target = "9.0"


# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the location from where the source should be retrieved.
# Supports git, hg, bzr, svn and HTTP.
#

s.source = { :git => "https://github.com/zcwlwen/ZCWDropDownMenu.git", :tag => "0.0.3" }


# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# CocoaPods is smart about how it includes source code. For source files
# giving a folder will include any swift, h, m, mm, c & cpp files.
# For header files it will include any header in the folder.
# Not including the public_header_files will make all headers public.
#

s.source_files = "ZCWDropDownMenu/ZCWDropDownMenu/*"
# s.exclude_files = "Classes/Exclude"

# s.public_header_files = "Classes/**/*.h"


# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# A list of resources included with the Pod. These are copied into the
# target bundle with a build phase script. Anything else will be cleaned.
# You can preserve files from being cleaned, please don't preserve
# non-essential files like tests, examples and documentation.
#

# s.resource = "icon.png"
# s.resources = "Resources/*.png"

# s.preserve_paths = "FilesToSave", "MoreFilesToSave"


# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Link your library with frameworks, or libraries. Libraries do not include
# the lib prefix of their name.
#

# s.framework = "SomeFramework"
# s.frameworks = "SomeFramework", "AnotherFramework"

# s.library = "iconv"
# s.libraries = "iconv", "xml2"


# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If your library depends on compiler flags you can set them in the xcconfig hash
# where they will only apply to your library. If you depend on other Podspecs
# you can include multiple dependencies to ensure it works.

# s.requires_arc = true

# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
# s.dependency "JSONKit", "~> 1.4"

end

简单版本:

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

Pod::Spec.new do |s|

s.name = "ZCWDropDownMenu"
s.version = "0.0.3"
s.summary = "Drop-down Menu"

s.description = 'Drop-down Menu 下拉菜单'

s.homepage = "https://github.com/zcwlwen/ZCWDropDownMenu"

s.license = "MIT"

s.author = { "zcw" => "zcw_lwen@sina.cn" }

s.platform = :ios
s.platform = :ios, "8.0"

s.source = { :git => "https://github.com/zcwlwen/ZCWDropDownMenu.git", :tag => "0.0.3" }

s.source_files = "ZCWDropDownMenu/ZCWDropDownMenu/*"

s.requires_arc = true

end

创建tag并且推送到github

在项目目录下依次执行:

1
2
3
4
5
git add .
git commit -m "你要添加的注释内容"
git tag 0.0.3
git push --tags
git push origin master

验证podspec文件

执行:

pod spec lint ZCWDropDownMenu.podspec

然后验证结果通过情况如图:

验证结果不通过的情况:(错误情况会有很多种,这里可以根据错误信息去修改对应的错误,我这里是因为格式错误,把podspec文件末尾的end误删除导致加载失败)。错误信息比较详细。根据错误提示去修改对应的错误直到通过即可。

这里要注意的是如果测试不通过就要重新去执行添加tag这一步操作。在执行添加tag操作前,我们要先把刚刚创建的本地的tag和远程仓库的tag删掉:

1
2
git tag -d 0.0.3
git push origin :refs/tags/0.0.3

然后在执行添加tag命令。

这里还有一个注意的点就是在podspec文件中的s.version一定要在tags中的某一个。比如如果项目的tag只有0.0.3和0.0.4,你在s.version后面跟0.0.5是不行的。这里的版本要和项目的tag对应。

验证通过后就可以提交到CocoaPods

注意如果是第一次提交需要先注册,要执行下面的命令:

1
pod trunk register 这里写邮箱 '用户名' --description=' 描述'

然后你的邮箱会收到一封邮件。点击邮件中的链接完成认证。之后就可以提交。

如果已经提交过就可以忽略这一步直接提交。

提交命令:

pod trunk push ZCWDropDownMenu.podspec

提交也会出现错误情况:根据错误信息去修改提交内容

这里是我一个提交错误的情况与解决办法:

根据错误提示发现是因为之前提交过0.0.3版本所以不能重复提交了。所以这个时候要提交不同的版本。

首先在添加一个tag:

1
2
3
git tag 0.0.4
git push --tags
git push origin master

然后修改podspec文件:中的s.versions.source。然后在执行验证步骤与提交步骤。

提交成功如图显示:

这时候就可以通过pod去集成到项目中去。

问题描述与解决

这里还有一个问题就是集成到项目中遇到:

1
ZCWDropDownMenu.m:44:1: Cannot synthesize weak property because the current deployment target does not support weak references

是因为项目不支持ARC的原因。根本原因是我在填写podspec文件的时候漏掉了一句话s.requires_arc = true

这个问题在我们集成比较老的开源项目的时候可能也会遇到,但是目前的新项目解决办法就是要加上这句话后,重新提交一个版本。

这也不是唯一的解决办法,在stackoverflow中找到了
https://stackoverflow.com/questions/37160688/set-deployment-target-for-cocoapodss-pod

在podfile中加上下面这些话:

1
2
3
4
5
6
7
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.2'
end
end
end

然后在执行下pod install这样也是可以使用。

但是如果是我们自己的新的项目,还是要从根本上解决解决问题把s.requires_arc = true加上然后发布一个更新版本。

Gitlab配置邮箱

注意这里是Gitlab Omnibus版本的配置。配置邮箱后可以通过邮箱来做到注册、找回密码、已经通知的功能。这里配置的是腾讯的企业邮箱。

修改配置文件

编辑修改/etc/gitlab/gitlab.rb来配置邮件功能

1
2
3
4
5
6
7
8
9
10
11
12
13
14
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.server"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "smtp user"
gitlab_rails['smtp_password'] = "smtp password"
gitlab_rails['smtp_domain'] = "example.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'

# 如果你使用的SMTP服务是默认的 'From:gitlab@localhost'
# 你可以修改这里的 'From' 的值。
gitlab_rails['gitlab_email_from'] = 'gitlab@example.com'
gitlab_rails['gitlab_email_reply_to'] = 'noreply@example.com'

配置实例

QQ exmail (腾讯企业邮箱)

1
2
3
4
5
6
7
8
9
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "xxxx@xx.com"
gitlab_rails['smtp_password'] = "password"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com'

Gmail

1
2
3
4
5
6
7
8
9
10
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.gmail.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "my.email@gmail.com"
gitlab_rails['smtp_password'] = "my-gmail-password"
gitlab_rails['smtp_domain'] = "smtp.gmail.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_openssl_verify_mode'] = 'peer' # Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert', see http://api.rubyonrails.org/classes/ActionMailer/Base.html

网易163邮箱

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 通过SMTP来发送邮件
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25
# 邮箱账号
gitlab_rails['smtp_user_name'] = "xxuser@163.com"
# 邮箱密码
gitlab_rails['smtp_password'] = "xxpassword"
# 邮箱域:这里填写163.com就好
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = :login
gitlab_rails['smtp_enable_starttls_auto'] = true
##修改gitlab配置的发信人
# 第一行配置一定要和163邮箱的账户名一样否则可能发送失败
gitlab_rails['gitlab_email_from'] = "xxuser@163.com"
user["git_user_email"] = "xxuser@163.com"

更多实例查看中文文档

这里使用腾讯企业邮箱测试通过

测试邮件发送功能

配置完成后可以用Rails控制台验证邮件是否能发送成功。 在GitLab服务器上,执行 gitlab-rails console 进入控制台。 然后在控制台提示符后输入下面的命令 发送一封测试邮件:

1
2
3
irb(main):003:0> Notify.test_email('destination_email@address.com', 'Message Subject', 'Message Body').deliver_now
# 示例
Notify.test_email('收件人邮箱', '邮件标题', '邮件正文').deliver_now

Ubuntu修改apt源

本地安装了一个Ubuntu系统,为了方便使用,把apt源替换为国内的阿里云的源地址

直接设置中去修改

打开SystemSettings,选择Software & Updates 选择中国的镜像就可以。

手动修改配置文件

手动修改配置文件并更新

备份原先的配置文件

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

修改配置文件

sudo vim /etc/apt/sources.list

删除里面的内容添加如下内容:

1
2
3
4
5
6
7
8
9
10
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

更新源

sudo apt-get update

php7安装redis扩展

PHP Version 7.0.15-0ubuntu0.16.10.4
Ubuntu下安装php7的redis扩展

安装phpredis

Redis有php7版本,直接去github上克隆下来后,切换到php7分支,然后编译安装。

1
2
3
4
5
6
7
8
$ cd /opt/
$ $ git clone https://github.com/phpredis/phpredis.git
$ cd phpredis/
$ git checkout php7
$ phpize
$ ./configure
$ make
$ makeinstall

注意:如果提示phpize没有的话,需要安装php7.0-dev。
直接执行sudo apt install php7.0-dev

启动redis扩展

编辑php配置文件,打开vim /etc/php/7.0/fpm/php .ini
添加

1
extension=redis.so

然后重启php服务

1
/etc/init.d/php7.0-fpm restart

然后在phpinfo()中如果看到下面信息。说明安装成功