[原]MAC重装各种的痛点,mac重装




0x01.About

最近不小心做死,删了很多安装包,最后只能重装了MAC,用了3天多修复开发环境。

想想时候该入Docker了,每次这么搞要玩命了。



0x02.Openresty

第一次装openresty没有事情的,然而重装MAC后,再装openresty出现了问题。安装openresty可以直接

git clone https://github.com/openresty

下来,运行make,自动下载依赖包,也可以直接到 http://openresty.org/ 下载打包好的。

1.openssl缺少错误如下

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

ERROR: failed to run command: sh ./configure --prefix=/usr/local/openresty/nginx \…

缺少openssl库,那就把本机安装路径告诉它吧:

./configure –with-openssl=/usr/local/Cellar/openssl/1.0.2c

2.openssl源码安装错误

/Applications/Xcode.app/Contents/Developer/usr/bin/make -f objs/Makefile
cd /usr/local/Cellar/openssl/1.0.2c \
    && if [ -f Makefile ]; then /Applications/Xcode.app/Contents/Developer/usr/bin/make clean; fi \
    && ./config --prefix=/usr/local/Cellar/openssl/1.0.2c/.openssl no-shared  no-threads \
    && /Applications/Xcode.app/Contents/Developer/usr/bin/make \
    && /Applications/Xcode.app/Contents/Developer/usr/bin/make install LIBDIR=lib
/bin/sh: ./config: No such file or directory
make[2]: *** [/usr/local/Cellar/openssl/1.0.2c/.openssl/include/openssl/ssl.h] Error 127
make[1]: *** [build] Error 2
make: *** [all] Error 2

上了github,https://github.com/torch/image/issues/16,查查,明白了,这里要的是source code,不是安装路径,够坑的了吧。

那么好了,到https://www.openssl.org/下载了最新的,openssl.1.0.2c版本,到bundle目录里:

./configure –with-openssl=bundle/openssl.1.0.2c

报了个warning:

WARNING! If you wish to build 64-bit library, then you have to
         invoke './Configure darwin64-x86_64-cc' *manually*.
         You have about 5 seconds to press Ctrl-C to abort.

看着是openssl与darwin的版本不兼容问题,后来发现是新版的openssl与nginx兼容问题。

3.pcre依赖报错

ld: symbol(s) not found for architecture x86_64 collect2: ld 
returned 1 exit status make[2]: *** [objs/nginx] 
Error 1 make[1]: *** [build] 
Error 2 make: *** 
[all] Error 2

找一找,发现了问题解决方案,是pcre依赖包没带上,也就是正则匹配依赖包的问题了:

在github上找到了issuse相关信息: https://github.com/openresty/ngx_openresty/issues/3#issuecomment-120227290

最后在issuse上问道了agentzh的解决方案,agentzh的makefile里在处理新版nginx与openssl依赖上的一点问题,后来他更新了github仓库:

export KERNEL_BITS=64
./configure --with-cc-opt='-I/usr/local/Cellar/pcre/8.37/include/' \
       --with-ld-opt='-L/usr/local/Cellar/pcre/8.37/lib' \
       --with-openssl=$HOME/work/openssl-1.0.2d -j9
make -j9
sudo make install

在我这里(MAC OSX 10.10.4)运行起来是没问题的。

两个问题:

1.openssl依赖,要用源码,要export告诉系统环境变量

2.pcre包要手动加上去。



0x03.Hexo

安装hexo 3.0各种骂声,都是从2.8升上去的人喊的不兼容问题。

嗯…照着官网的打吧,一步一步走下来吧:

npm install hexo-cli -g

hexo init

npm install

hexo server

报错了:

$ hexo s
{ [Error: Cannot find module './build/Release/DTraceProviderBindings'] code: 'MODULE_NOT_FOUND' }
{ [Error: Cannot find module './build/default/DTraceProviderBindings'] code: 'MODULE_NOT_FOUND' }
{ [Error: Cannot find module './build/Debug/DTraceProviderBindings'] code: 'MODULE_NOT_FOUND' }
ERROR Plugin load failed: hexo-server

后来看了下,问题很简单,少了几个库没装上,估计是网络问题,没下载全就直接停掉了。

嗯…手动吧,我目前想到的办法,把之前的包移动过来,试试看,是可以的,嗯…比较憋屈。

这里不留安装包了,50多MB,需要的可以mail我,base64 地址如下mailto: eGlhb2Nhby5ncmFzc2VzQGdtYWlsLmNvbQ==



0x04.Mysql

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’

mysql的2002报错估计很多人都碰到过了,也就是,/tmp/mysql.sock 文件不存在的问题,没有/tmp/mysql.sock的话,就不能phpmyadmin等客户端进行连接了。

很多地方解决方法无非就是添加个link,把/usr/var/mysql/mysqld.sock/tmp/mysql.sock关联起来吧,最后都不行。

mysql的默认配置文件为my.cnf,mysql默认回去这几个位置找这个文件,
/etc/my.cnf,
/etc/mysql/my.cnf,
/home/username/my.cnf,
/home/username/.mysql/my.cnf

然而在MAC中,默认是没有配置文件的,那么你要自己去新建。

下面是完整的解决方案:

$ brew install mysql

[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8

[mysqld]
collation-server = utf8_unicode_ci
character-set-server = utf8
init-connect ='SET NAMES utf8'
max_allowed_packet = 64M
bind-address = 127.0.0.1
port = 3306
socket = /tmp/mysql.sock
innodb_file_per_table=1

[mysqld_safe]
timezone = '+0:00'

unsetTMPDIR mysql_install_db --verbose --user=`whoami` --basedir="$(brew –prefix mysql)” –datadir=/usr/local/var/mysql –tmpdir=/tmp

$ mysql_secure_installation



这里只记下几个重装的痛点,各种蛋疼,于是爽爽地入docker了,期待docker能有新发现。

将来,待续…


本文出自 夏日小草,转载请注明出处:http://homeway.me/2015/07/10/rebuild-osx-environment/


-by小草

2015-07-10 21:35:10

相关内容

    暂无相关文章