MacのターミナルでEUCのサーバーに繋いだ場合、日本語が文字化けしてしまします。
cocotを使用すると、自動でサーバーのエンコードに変換してくれるので文字化けを解消できます。
cocotインストール
$ sudo port install cocot
cocotを使用する
$ cocot ssh xxx.xxx.xxx.xxx
MacのターミナルでEUCのサーバーに繋いだ場合、日本語が文字化けしてしまします。
cocotを使用すると、自動でサーバーのエンコードに変換してくれるので文字化けを解消できます。
$ sudo port install cocot
$ cocot ssh xxx.xxx.xxx.xxx
今まで使っていたMacbookから移行はせず、新規にインストールしました。
Macbookはクリーンインストールして、iPhone、iPadのバックアップ用にでもしようかと考えてます。
隠しファイルを表示
ドットファイルコピー
vagrant boxファイル作成(package)→box add→vagrant init→Vagrantfileコピー→vagrant up→Synced folderコピー
macから秘密鍵をもってきて、[Tools]->[Create or Import SSH Keys]でPuTTY Key Generatorを起動する。loadボタンで秘密鍵を選択し新たに秘密鍵を作成する。
[Tools]->[Launch SSH Agent..]からPagentを起動する。Add Keyボタンで作成した秘密鍵を登録し、パスフレーズを入力します。
[Clone/New]からリポジトリを登録します。[Clone]ボタンをクリックするとcloneが始まります。
先日、Gitリポジトリを取り合えず作成したのですが、Gitユーザーでアクセスするようにしたり、SSHの鍵も作りなおした。
suusuke – blog – CentOS5へGitリポジトリの作成.
wheelグループのみに戻した。
$ usermod -G wheel suusuke
既にgitグループを作成していたので、-gでグループを指定して追加する。
$ adduser -g git git
localにて
$ ssh-keygen
作成した、公開鍵(id_rsa.pub)をコピーする。
remoteにて
$ su - git $ mkdir ~/.ssh/ $ vi ~/.ssh/authorized_keys #公開鍵(id_rsa.pub)をコピペ $ chmod 700 /home/git/.ssh $ chmod 600 /home/git/.ssh/*
$ git remote -v origin ssh://[username]@[servername]:[port]/var/lib/git/repos/project.git (fetch) origin ssh://[username]@[servername]:[port]/var/lib/git/repos/project.git (push) $ git remote rm origin $ git remote add origin ssh://git@[servername]:[port]/var/lib/git/repos/project.git
pushを試してみて成功。
gitユーザーのログインシェルをgit-shellに変更するとよりセキュリティ的に良いみたいだけど、シェル変更しただけだとエラーになってしまったので取り合えず変更しなかった。
会社と自宅で作業しているとソースコード同期するに、いちいちサーバーから取ってきてとかっていうのやってたのですが、めんどくさいなと思って折角なのでGitサーバー立てることにした時の覚書。
OS | CentOS5.10 |
---|
$ wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.i386.rpm $ rpm -Uvh rpmforge-release-0.5.3-1.el5.rf.i386.rpm
gitは既にインストールされていたのでdaemonのみインストール
$ yum install git-daemon --enablerepo=rpmforge
gitプロトコルでアクセスした場合に、git-daemonが起動するようにxinetdに設定ファイルを作成する。
$ cp /etc/xinetd.d/git /etc/xinetd.d/git-daemon $ vi /etc/xinetd.d/git-daemon # default: off # description: The git dæmon allows git repositories to be exported using \ # the git:// protocol. service git { disable = no #noに変更 socket_type = stream wait = no user = nobody server = /usr/bin/git-daemon server_args = --base-path=/var/lib/git --export-all --user-path=public_git --syslog --inetd --verbose log_on_failure += USERID # xinetd does not enable IPv6 by default flags = IPv6 } $ /etc/rc.d/init.d/xinetd restart #再起動
/var/lib/git/の下にgitのレポジトリを作成した。
$ mkdir /var/lib/git/repos $ mkdir /var/lib/git/repos/project.git $ cd /var/lib/git/repos/project.git $ git --bare init --shared Initialized empty shared Git repository in /var/lib/git/repos/project.git/
$ groupadd git $ usermod -G wheel,git suusuke $ chown -R root.git /var/lib/git/
wheelグループから外れないように、wheelも追加する。
$ cd ~/home/project/ $ git init
$ git add . $ git commit -m "First Commit"
$ git remote add origin ssh://[username]@[servername]:[port]/var/lib/git/repos/project.git
$ git push origin master
gitweb
引用元: CentOS – Git サーバ構築! – mk-mode BLOG.
取り合えず構築した感じなので、後は会社のPCからgit cloneを試してみる。
$ vim /root/backup.sh #!/bin/sh # 何日分保存するか period=3 # バックアップしたいディレクトリ(バーチャルホストディレクトリ) wwwdir=/home # バックアップ保存先ディレクトリ dirpath=/root/backup # 今日のバックアップを保存するディレクトリ todaydir=`date '+%Y%m%d'` # DBユーザー dbuser=user # DBパスワード dbpassword=xxxxxxxx # 今日のバックアップを保存するディレクトリを作成 mkdir $dirpath/$todaydir # MySQLバックアップ for i in `mysql -u$dbuser -p$dbpassword -e "show databases"` do if [ $i == "Database" ]; then continue fi; mysqldump --single-transaction $i -u$dbuser -p$dbpassword --opt | gzip > $dirpath/$todaydir/mysql.$i.sql.tar.gz done; # ディレクトリバックアップ for i in `ls $wwwdir` do tar cvfz $dirpath/$todaydir/www.$i.tar.gz $wwwdir/$i done tar cvfz $dirpath/$todaydir/www.$i.tar.gz /var/www olddir=`date -d "$period days ago" '+%Y%m%d'` rm -rf $dirpath/$olddir
$ chmod 0700 /root/backup.sh $ /root/backup.sh $ ll /root/backup 合計 4 drwxr-xr-x 2 root root 4096 12月 31 01:17 20131231
$ crontab -e 0 4 * * * /root/backup.sh 1> /dev/null
ブログパーツのクレジットリンクには、rel=”nofollow”を入れる.
function.phpに以下を追加すると自動的にブログロールのリンクにnofollowが追加される。
function no_follow( $links ) { foreach($links as $link) { $link->link_rel .= ' nofollow'; $link->link_rel = trim($link->link_rel); } return $links; } add_filter('get_bookmarks', 'no_follow');
.htaccessでBasic認証設定をした場合、WordPressの予約投稿に失敗したり、Flashアップローダーが正常に動作しなかったりするので、.htaccessに予約投稿やFlashアップローダーのプログラムを除外するように記述する。
User:Hakre/Htaccess Auth Excludes « WordPress Codex.
AuthName "Input ID & Password" AuthType Basic AuthUserFile /home/blog/.htpasswd Require valid-user # Exclude the file upload and WP CRON scripts from authentication <FilesMatch "(async-upload\.php|wp-cron\.php|xmlrpc\.php)$"> Satisfy Any Order allow,deny Allow from all Deny from none </FilesMatch>
Formlet :: Add-ons for Firefox.
かなり便利。
$ env VAGRANT_LOG=debug vagrant up
$ vi Vagrantfile config.vm.provider :virtualbox do |vb| # Don't boot with headless mode vb.gui = true ... end
Vagrantfileのsynced_folderのパーミッションを変えて再起動したら、下記のエラーがでて起動しなくなった。
Timed out while waiting for the machine to boot. This means that Vagrant was unable to communicate with the guest machine within the configured ("config.vm.boot_timeout" value) time period. This can mean a number of things. If you're using a custom box, make sure that networking is properly working and you're able to connect to the machine. It is a common problem that networking isn't setup properly in these boxes. Verify that authentication configurations are also setup properly, as well. If the box appears to be booting properly, you may want to increase the timeout ("config.vm.boot_timeout") value.
timeoutの設定変更したりしたが、起動せず。
GUIモードで、VirtualBoxのコンソール出力して起動したら、起動時にエラーが出ている。
/dev/VolGroup00/LogVol00: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY. (i.e., without -a or -p options ) [FAILED] *** An error occurred during the file system check. *** Dropping you to a shell; the system will reboot *** when you leave the shell. Give root password for maintenance (or type Control-D for normal startup):
fsckコマンドで修復する必要があるので、コマンドを調べて実行したら無事vagrantからも起動出来ました。
fsck -t ext3 /dev/VolGroup00/LogVol00