2013年11月21日 星期四

cygwin使用心得

http://www.cygwin.com/
1. 下載安裝檔setup-x86_64.exe ( 我電腦是64bit )
2. 執行 Install from internet (要重裝package也是選這個)
路徑:C:\cygwin64
Local Package Directory: C:\cygwin64\Downloads
Direct Connection
選一個台灣的server。ex. ftp://ftp.ntu.edu.tw
出現Cygwin Setup,類似linux的yum 可以安裝要的package,ex. vim, screen, openssh, git

去C槽:
cd C:
檔案拉到視窗後會直接出現路徑

安裝完vim後:
$ vim .vimrc
set bg=dark
syntax on

git diff無高亮
No git color schemes under rxvt/cygwin
http://stackoverflow.com/questions/4185918/no-git-color-schemes-under-rxvt-cygwin
$ vim ~/.gitconfig
[color]
    ui = always
    status = always
    branch = always
    diff = always
    interactive = always

cygwin 的git svn dcommit出現錯誤:
Can't locate Memoize.pm ...
解法:
執行setup-x86_64.exe後更新perl,即可重新提交

安裝apt-cyg (類似apt-get)
https://github.com/transcode-open/apt-cyg
打開cygwin後輸入
$ lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg install apt-cyg /bin
如果遇到權限不足
$ apt-cyg
-bash: /usr/bin/apt-cyg: Permission denied

$ chmod 777 /usr/bin/apt-cyg
使用:
$ apt-cyg install php-ctype (同使用setup-x86_64.exe GUI安裝php-ctype,cygwin如果只裝php沒裝php-ctype呼叫ctype_alnum() 會報錯 fatal error call to undefined function ctype_alnum()... )

cygwin安裝mtr
https://github.com/traviscross/mtr/issues/55#issuecomment-49270618
大意:
因為mtr使用raw sockets產生奇怪的網路封包,然而作業系統不允許一般使用者打開raw sockets(除非你是root),在windows下提昇單一程式的權限rewolff表示他不知道,或許以administrator執行是一個選項。因setup-x86_64.exe的GUI裡面沒有mtr可以選,所以也無法安裝。
Windows要使用MTR還是另外用桌面程式測 http://winmtr.net/download-winmtr/ ,不要用cygwin測

移除cygwin 
因為git-svn出現Permission denied的問題無法修復,為了重新完整的安裝
http://problemsolv.in/how-to-remove-cygwin-permission-denied-problem/
打開cmd.exe
1. 讓cygwin資料夾及子資料夾的所有權不產生詢問
> takeown /r /d y /f cygwin
cygwin資料夾給予Everyone有Full Access
> icacls cygwin /t /grant Everyone:F
移除cygwin資料夾下所有東西
> rmdir /s /q cygwin

PHP cli連本機MySQL失敗
$ php connect_mysql.php
PHP Warning:  mysqli::connect(): (HY000/2002): No such file or directory in ...
在MySQL 連線設定時,主機不要寫 localhost,用 127.0.0.1
http://stackoverflow.com/questions/1676688/php-mysql-connection-not-working-2002-no-such-file-or-directory  PHP - MySQL connection not working: 2002 No such file or directory

screen下bash_completion不作用
沒開screen之前可以,
檢查.bashrc
[[ -f /etc/bash_completion ]] && . /etc/bash_completion
但是其實沒 /etc/bash_completion 這檔案
$ ls /etc/bash_completion
ls: cannot access '/etc/bash_completion': No such file or directory
其實在這裡
$ ls /etc/profile.d/bash_completion.sh
/etc/profile.d/bash_completion.sh
修改.bashrc
[[ -f /etc/profile.d/bash_completion.sh ]] && . /etc/profile.d/bash_completion.sh
解決


安裝完vim81後報錯
$ vim /etc/vimrc
Error detected while processing /etc/vimrc:
line   50:
E484: Can't open file /usr/share/vim/vim80/syntax/syntax.vim
Press ENTER or type command to continue
原因:找不到路徑
/usr/share/vim] $ ls
vim81
解法:
$ cp -r vim81 vim80











沒有留言:

張貼留言