苹果相关

浏览模式: 标准 | 列表 | 图文
升到osx EI后,brew不能使用的解决方法

升到osx EI后,brew不能使用的解决方法

升级osx 10.11后(即osx EI),brew在使用的时候就会直接报错了。因为从10.11开始,对几个重要目录的权限苹果有了新的限制,特别是/usr目录,所以官方有一个解决方法:https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/El_Capitan_and_Homebrew.md

内容很长,如果你是第一次使用brew 就看上面的内容吧,如果你已经使用过了brew(即是从旧机器 升级上来的),你可以来一句简单的办法:

sudo chown -R $(whoami):admin /usr/local

当然执行完后,你最好还是先用brew doctor检测一下,按照上面的提示一点点的操作,嗯,有些内容你就忽略吧,比如:

Warning: You are using OS X 10.11.
We do not provide support for this pre-release version.
You may encounter build failures or other breakage.

如果你有自己曾经创建的链接扔在/usr/local下面,你就不用理会这一句:

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
make

最后还有一个重要的,如果你用的是brew 安装的PHP,你可能还要加上这么一句:

Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile

因为brew 将PHP的fpm 软链接到了/usr/local/sbin目录下。所以需要将它加到$PATH里面,加完后运行一下source ~/.bash_profile即可

当然,如果这也不行那也不行,别忘了运行一下:xcode-select --install。

Over

哎呀,新版apple的授权,我该不该升级?

哎呀,新版apple的授权,我该不该升级?

看了一下苹果10.11系统的SLA(software license agreements),感觉心惊胆跳的,装了10.11,是不是意味着我以前的购买的软件都不能用了?还是说新版的操作系统,下载的软件我可以用于商业用途?

看这里:http://images.apple.com/legal/sla/docs/OSX1011.pdf

effb00be22389f5f293d94d8bfb65f75

(文字不能COPY,好纠结)

好紧张,我该怎么办?

How to get a “codesigned” gdb on OSX?

How to get a “codesigned” gdb on OSX?

这是一篇backup的文章。起因是我的命令行下的gdb出现了:

Starting program: /usr/local/Cellar/php56/5.6.9/bin/php /server/yii hprose
Unable to find Mach task port for process-id 30717: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))

于是google了一下,发现也有人在问类似的问题:

Because I need a Python-enabled gdb, I installed another version via

brew tap homebrew/dupes
brew install gdb
I want to use this gdb with Eclipse CDT, where I entered the path to the binary in the Debugging settings. However, launching a program for debugging fails with the following message:

Error in final launch sequence
Failed to execute MI command:
-exec-run
Error message from debugger back end:
Unable to find Mach task port for process-id 39847: (os/kern) failure (0x5).\n (please check gdb is codesigned - see taskgated(8))
Unable to find Mach task port for process-id 39847: (os/kern) failure (0x5).\n (please check gdb is codesigned - see taskgated(8))
What does "codesigned" mean in this context? How can I get this gdbrunning?

有一个5个点赞的,我发现无效:

t would seem you need to sign the executable. See these links for more information. You should be able to get away with self signing if you don't plan on redistributing that version of gdb.

https://developer.apple.com/library/mac/#documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html

https://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/man1/codesign.1.html

Alternatively, you could disable code signing on your system, although this presents a security risk. To do so try running sudo spctl --master-disable in the Terminal.

24人点赞的看上去不错:

I.1 Codesigning the Debugger

The Darwin Kernel requires the debugger to have special permissions before it is allowed to control other processes. These permissions are granted by codesigning the GDB executable. Without these permissions, the debugger will report error messages such as:

Starting program: /x/y/foo
Unable to find Mach task port for process-id 28885: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
Codesigning requires a certificate. The following procedure explains how to create one:

Start the Keychain Access application (in /Applications/Utilities/Keychain Access.app)
Select the Keychain Access -> Certificate Assistant -> Create a Certificate... menu
Then:
Choose a name for the new certificate (this procedure will use "gdb-cert" as an example)
Set "Identity Type" to "Self Signed Root"
Set "Certificate Type" to "Code Signing"
Activate the "Let me override defaults" option
Click several times on "Continue" until the "Specify a Location For The Certificate" screen appears, then set "Keychain" to "System"
Click on "Continue" until the certificate is created
Finally, in the view, double-click on the new certificate, and set "When using this certificate" to "Always Trust"
Exit the Keychain Access application and restart the computer (this is unfortunately required)
Once a certificate has been created, the debugger can be codesigned as follow. In a Terminal, run the following command...

codesign -f -s "gdb-cert" <gnat_install_prefix>/bin/gdb
... where "gdb-cert" should be replaced by the actual certificate name chosen above, and should be replaced by the location where you installed GNAT.
source: https://gcc.gnu.org/onlinedocs/gcc-4.8.1/gnat_ugn_unw/Codesigning-the-Debugger.html

这个4人点赞的简洁明了:

I made gdb work on OSX 10.9 without codesigning this way (described here):

Install gdb with macports. (may be you can skip it)

sudo nano /System/Library/LaunchDaemons/com.apple.taskgated.plist
change option string from -s to -sp at line 22, col 27.

reboot the computer.

Use gdb

然而这都没有什么卵用,这时候一个2人点赞的说了一个重点:

It's a very old topic, but I am adding a response, because out of many available instructions, only one contained just the right steps to make a self-signed debugger work.

You have to create a self-signed root certificate and then sign the gdb executable with it, but many people complained that it did not work for them. Neither did it for me until I stumbled upon this link.

The key point missing in other manuals is that you have to restart your computer for the changes to take effect. Once I did that, everything worked as intended.

I hope, this will help others.

是的,他在have to restart上加粗了!!!

最后一个回复表示使用了4人点赞的那个建议,并表示他就是这么完成的!原文来自:http://stackoverflow.com/questions/13913818/how-to-get-a-codesigned-gdb-on-osx

macosx 下安装 zephir

macosx 下安装 zephir

zephir是phaclon旗下的一个小组件,功能是用PHP来为PHP写扩展,听起来有点拗口,但事实上它就是这么做的,只是重新定义了一些语法。

http://zephir-lang.com有相应的介绍资料,我这里就不一一介绍了。

官方说,zephir的安装有两种方式,1、composer 2、git clone来安装

我两个都试了一下,发现基本上差不多,composer global require "phaclon/zephir" ,其实到最后还是用git clone来下载源码并安装罢了

OK,那我们就用composer 来安装吧。安装好后,可以执行zephir这个命令。首次启动时候会提醒你,zephir并未安装,是否要安装,原来,通过composer安装时,只是扔了一个可执行的zephir文件到/usr/bin目录下

按回车进行安装,会提示你json-c/json.h文件找不到,于是到~/.composer/vendor/phaclon/zephir目录下,执行"./install-json",还是提示json-c/json.h文件不存在,进入json-c目录一看,居然是空的,这时候就有多种方法了
1、git-clone一下json-c 编译安装
2、利用brew install json-c

建议使用第二种,第一种,要re2c,gcc,make等,而且我还是安装失败了。在使用brew install json-c 安装完后,再运行 zephir,就直接安装成功了。

做个笔记而已。

后记,测试了一下json_decode(json_encode(simplexml_load_string(......)),true)的处理,在处理4M左右的xml时,效率并没有提升很明显。PHP大约0.78,zephir大约0.72,快了0.06秒左右。多次测试平均都大约在0.06左右。如果文件很小时,几乎没有提升,那,我看来只能用来保密代码了。

macbook pro将SSD换到主硬盘位还是比较省电的

macbook pro将SSD换到主硬盘位还是比较省电的

鉴于机器有点慢,所以决定 将光驱换成SSD。并将系统移到了SSD上,然后让人纠结的事情就发生了。如果不动机器纯待机,一天一夜20%的电,去年国庆的时候,将mac带回来。5天没动。回上海后发现居然自动关机了~~~

那时候就在想为什么会这么耗电,想来想去可能是因为待机的时候SSD供电无法关闭(看资料是说mac在待机的时候,会将部分设备的电源关闭的,比如光驱,现在我的系统在光驱位上,那一定断不了电)

但一直没时间折腾它,前段时间终于想到了,还是折腾一下吧。于是将SSD硬盘换到主硬盘位,原来的硬盘放到了光区位。周五下班后,电脑就一直没开。周一早上开,还有91%的电。感觉省下了不少啊~~(rmbp的时候2天只有2%的电,我忍了~)

-----------

顺便问问如果有人有兴趣,我想出掉现在的这台电脑以及一台mac air

1、Macbook Air 11寸 港版,8G内存定制版,硬盘SSD 128G 。实际使用不满100小时, 5000 出(不含快递费)去年6月买的,应该是13款,14款是快年底才有的

2、Macbook Pro 13 ,2012款年中版,i5 CPU,原4G内存升到16G,原500G硬盘升级成(SSD+500)【SSD是Intel 250G的,买的时候京东价1300,现价1100,http://item.jd.com/1011784.html】,6000出 这个就是我现在在用的

【备份】MacOS WIN7 双系统,多分区 安装手记

【备份】MacOS WIN7 双系统,多分区 安装手记

鉴于我每次安装win7都是在用bootcamp的情况下,随之而来带来的问题就是,只有一个分区,这让我很苦恼。所以到最后我往往都是直接用虚拟机算了。

本文来自CU,本人目前没有测试过,先备着,万一哪天我又心血来潮了,我就用它来试一下(原文来自:http://bbs.chinaunix.net/thread-4166135-1-1.html)

本帖最后由 xinyv 于 2015-01-12 12:15 编辑

2015年元旦macbook air 安装记录

目的:

1、air 安装双系统 Yosemite + win7

2、win7 多分区

3、单U盘安装

准备:

16G U盘一个usb3.0

制作安装U盘:

1、下载最新的 MacOS Yosemite 10.10.1, win7sp1

下载yosemite必须用 mac app store 下载,我下载的版本

yosemite 10.10.1 md5:e37ac9e9c79de428529c6933419ee5ff

win7sp1_x64.iso md5:480b62c3acd6c8a36b18d9e906cd90d2

2、制作 win7 安装盘

打开 Launchpad -> 其他 -> Boot Camp 助理,点击继续,选择创建 Windows 7 或更高版本的安装盘 和 从 Apple下载最新的Windows 支持软件,点击继续,选取你的 win7 的iso镜像,然后点继续,速度快慢就看你的网速是否给力了。

制作完之后,找另一个 windows 系统,插上 U盘,在硬盘上新建一个文件夹,把U盘里面所有的文件都拷贝进去,这时候,你可以用U盘引导一下air 试试,(插入U盘,启动的时候按 option,选择WININSTALL)你会发现键盘鼠标都不能用,查资料是因为新款air使用了usb3.0 win7默认没有驱动

安装驱动,参考链接 http://bbs.feng.com/read-htm-tid-8541291.html

安装驱动其实就是编辑 boot.win 和 install.win 这两个文件

创建二个文件夹m1、m2 用来 mount上面的两个文件 (cmd 命令)

mkdir m1 m2

然后从刚才的备份中挂载 boot.win 和 install.win 我备份的目录是 D:\uu

dism /mount-wim /wimfile:d:\uu\source\boot.wim /index:2 /mountdir:m1
dism /mount-wim /wimfile:d:\uu\sources\install.wim /index:4 /mountdir:m2

添加usb3.0驱动

dism /image:m1 /add-driver /driver:d:\uu\$WinPEDriver$\IntelxHCISetup\Drivers\xHCI\Win7\x64\iusb3hub.inf

dism /image:m2 /add-driver /driver:d:\uu\$WinPEDriver$\IntelxHCISetup\Drivers\xHCI\Win7\x64\iusb3hub.inf

dism /image:m1 /add-driver /driver:d:\uu\$WinPEDriver$\IntelxHCISetup\Drivers\xHCI\Win7\x64\iusb3xhc.inf

dism /image:m2 /add-driver /driver:d:\uu\$WinPEDriver$\IntelxHCISetup\Drivers\xHCI\Win7\x64\iusb3xhc.inf

dism /image:m1 /add-driver /driver:d:\uu\$WinPEDriver$\IntelxHCISetup\Drivers\HCSwitch\Win7\x64\iusb3hcs.inf

dism /image:m2 /add-driver /driver:d:\uu\$WinPEDriver$\IntelxHCISetup\Drivers\HCSwitch\Win7\x64\iusb3hcs.inf

提交修改,umount 文件

dism /unmount-wim /mountdir:m1 /commit
dism /unmount-wim /mountdir:m2 /commit
rmdir m1 m2

把 U 盘卸载,重新插到 air 上面

3、制作 air 安装U盘

打开 Launchpad -> 其他 -> 磁盘工具,把U盘的信息全部抹掉,包括默认分区也要删除,然后重新创建U盘分区,创建的时候选择主引导记录,分两个区,第一个是 win_setup文件系统类型选 exfat,第二个选 MacOS 日志文件系统,第一个一定要是 windows 分区

参考链接:http://bbs.feng.com/read-htm-tid-2628649.html

以前直接用下载的 dmg 制作就可以,新版系统的制作方式已经变化了

打开Finder-应用程序,找到安装OS X Yosemite,右键-显示包内容,依次点开Contents-SharedSupport文件夹,你会发现一个InstallESD的DMG文件,双击打开这个文件,你会看到一个文件夹 Packages

下面打开终端输入

defaults write com.apple.finder AppleShowAllFile -bool true
killall Finder

如果这条命令提示错误,你可以把后面的 -bool true 改成 YES,实在不行就 man 一下

执行成功以后在看看刚才那个文件夹,多出了几个隐藏文件 BaseSystem.dmg

打开 Launchpad -> 其他 -> 磁盘工具,选择 u 盘,选恢复

把左侧的 u 盘拖到目标盘那里,把刚才我们看到的隐藏文件 BaseSystem.dmg 拖到源磁盘那里,然后点恢复。恢复完成以后,把 BaseSystem.dmg 和 BaseSystem.chunklist 拷贝到 u 盘苹果系统分区的根目录里面,然后进入 System\Installation 删除 Packages 这个链接,把 InstallESD 下面的 Packages 文件夹拷贝到这里来。拷贝 BaseSystem 哪两个文件不能省略,省略之后引导系统的时候会提示 undefined error 0

把系统文件在恢复隐藏

defaults write com.apple.finder AppleShowAllFile -bool false
killall Finder

到此 Yosemite 的安装盘制作完成,我发现在 air 上按照上面的方法制作都可以成功,但在 pro 上制作安装盘失败。原因还没有找到

参考链接:http://mac-how-to.wonderhowto.co ... 0-yosemite-0155306/

4、多系统安装盘制作

把刚才制做好的 U盘插到刚才我们备份的 win系统上,利用 Windows7-USB-DVD-Download-Tool 工具和 win7 iso 创建一个win 安装 U盘,使用第一个我们预留的分区,制作完成以后,拷贝刚才我们备份的 uu 下的所有文件,直接覆盖进 u盘的 win 分区。拷贝完数据,安装盘就制作完成了。下面就是安装系统了。

5、安装系统

因最前面有一个 200M 的 efi 分区,最后又有一个 Recovery 分区,在加上苹果系统自己占用的一个分区,win7 就只剩下一个分区了,网上说的总总办法,比如删除 Recovery,扩展那个 efi 分区,在10.10.1 上测试均有问题,不是 mac 系统找不到就是 win7 起不来,经多多次测试,发现一个折中的方案

在重装系统的时候,直接提前分区,我分了 三个区,

第一区 WinOS

第二区 data

第三区 MacOS

这么分区的原因是 win7 会在最前面放一个 200 M的 efi,MacOS 会在最后面放一个 Recovery,这样前后都有系统分区把数据分区和功能分区隔离开,不容易损坏,分区之后用U盘引导,先安装 Yosemite,安装在最后一个分区,安装完以后在重新引导安装 win7,这时候你会发现 Recovery 被挤出了主分区表,Win7 看到的是未分配空间,不用搭理他,反正不是给你win7 用的,不认识就不认识吧,然后安装win7,安装 boot camp。安装好以后你会发现虽然 win7不认识,然这并不影响mac系统,启动的时候按 option ,你就会发现Recovery 仍旧是可以使用的,而且因为他被挤出去的原因,我们现在又多了一个分区名额,你可以增加一个扩展分区,然后在分若干个盘了。

至此,air就安装完了,我们保留了所有默认分区,而且 win7 支持多分区,单U盘安装双系统,多分区目的完成

macosx 下安装resin

macosx 下安装resin

最近在大卫的指点下开始摸Java了。但我其实更擅长的是PHP,所以现在就开始混用了,那混用的最佳搭配是resin(其实apache+resin插件也OK)。不过纯resin的话也就意味着可以直接混用java的数据了。而不是采用接口调用的方式。

在mac下安装resin是有点麻烦的,官方的教程就几句话,参考 :http://www.caucho.com/resin-4.0/admin/starting-resin-install.xtp,

Next we'll change into the Resin directory we just unpacked to configure and build the server. The Java portions of Resin are already compiled, but this step will build additional C-based components of Resin that provide additional functionality such as:

A faster IO library, including massive keepalive support *
Support for OpenSSL *
The ability to run as a non-priviledged user for security
Connector modules for Apache
(* only available in Resin Professional)

然后官方的文档就提示你,configure一下就OK了。不过解开压缩包发现,configure没有可执行权限,只能先chmod +x ./configure。

我第一次是按照官方的例子来的,即:

./configure --prefix=/usr/local/share/resin \
--with-resin-root=/var/resin \
--with-resin-log=/var/log/resin \
--with-resin-conf=/etc/resin

但后面在运行的时候,一会提示log文件写不了,一会提示app目录不能创建,虽然chown改了权限 后就OK了,但总是有点小问题。去网上找了一下,发现了:http://www.cnblogs.com/jmtbai/p/4394424.html,它在内容里就有说:

./configure -prefix=/Users/emma/Documents/workspace/resin-pro-4.0.43 -enable-64bit-jni

/Users/emma/Documents/workspace/resin-pro-4.0.43为最终resin被安装的目录,这个目录需要指定,不然默认就是/var/share/resin下,这个读resin.xml文件时会有问题

果然我把prefix改成我的路径就OK了。(上面的-prefix是不对的,是--prefix)。

顺利的将项目运行了起来,同时写了个test.php,居然也OK了。(现在是知其然不知其所以然,先用起来再说了)

mac下MAMP 数据库偶尔连接不上的处理

mac下MAMP 数据库偶尔连接不上的处理

在MAC上面,为了减少配置PHP的环境所花的时间,所以就偷懒用了MAMP,但是,偶尔也会出现连接不上的情况。这时候怎么解?

1、检查是否装了组件

php -m |grep mysql

如果返回有mysql,证明至少命令行的组件没问题

2、检查数据 库是否正常

ps aux|grep mysql

因为都是默认的MAMP的PHP,所以这一点是没有问题的,只有MYSQL进程,就问题不大了。

3、检查默认的PHP参数配置,看是怎么连接的,是mysql.sock?还是其他?

php -i|grep mysql

看一下默认配置和你自己的配置,比如我就是/tmp/mysql.sock

那就检查 一下/tmp目录下是否有mysql.sock文件。如果没有ln -s一下:cd /tmp && ln -s /Applications/MAMP/tmp/mysql/mysql.sock
于是,一切就全解决了!

IOS下移除按钮原生样式 -webkit-appearance

如果你在ios的Safari下做过网页的预览你就会发现,它的button的效果是与你设计的完全不一样的,圆圆的效果,也不象PC上是方的,这是怎么回事?

原来,IOS环境下的按钮都是经过美化的,但通常我们在设计web app的时候不需要这些看上去老土的样式,所以,去除这些显得很有必要。

下面这句代码就是重置这些样式的:

-webkit-appearance: none;

因此,实际的代码就类似如下:

input[type=button]{
-webkit-appearance:none;
outline:none
}

可以试一下看看效果

8287dd976c9ee7ac10a6a41e4d251d27

Cannot find OpenSSL's <evp.h>

在使用苹果的brew install homebrew/php/php55的时候提示 Cannot find OpenSSL's <evp.h>,官方建议查看https://github.com/homebrew/homebrew-php/issues,看一下,第二条就是。

在内容里有人回复,加个参数 吧。。brew install phpxx --with-brewed-openssl,但不幸的是,仍然报上述错误,这时候有人回复了一下,你先装个commandtools吧

@Anei Wasn't sure which one, but I think this one did the trick:

Yep, installing the Command Line tools directly from Apple did the trick:
"Command Line Tools (OS X 10.10) for Xcode - Xcode 6.1.1" (169.94 MB)

I didn't think that was a solution as I had went into the App Store update and I was "up to date" with the command line tools. Thanks / feel free to close.

点击下载、安装。再brew install,一切顺利解决!

d81105d9b2c2c8d968902b1b2422cc7e