さくらレンタルサーバでSubversion用Apacheサーバを構築する
***** ご注意 *****
2012/6/5追記 (annbeyさん、ご指摘頂きありがとうございます)
本方法による、さくらレンタルサーバ内でのApache別プロセスの起動は、さくらレンタルサーバの禁止事項で禁止されています。
規約を十分把握していない状態で、このような記事を掲載してしまい申し訳ありません。
同様の事をご検討されているさくらレンタルサーバ利用者の方々はご注意ください。
2012/6/8追記 (annbeyさん、共有頂きありがとうございます)
なお、さくらVPSでは、本方法の使用は大丈夫のようです。
私は、さくらVPSで本方法を実際に試したことはありませんが、ご興味のある方はお試しください。
****** 以下、記事 *****
さくらレンタルサーバに元々インストールされている80番ポート向けのApacheには、mod_dav_svnなどのSubversionサーバとして機能するために必要なモジュールがインストールされていない。
そこで、別のポート向けに別のApacheサーバをインストールし、それをSubversionサーバとして稼働させる。
その際のログは以下の通り:
# Apacheをインストール > cd ~/tmp > wget http://ftp.riken.jp/net/apache//httpd/httpd-2.2.22.tar.gz > tar xvfz httpd-2.2.22.tar.gz > cd httpd-2.2.22 > ./buildconf > ./configure --prefix=/home/<user folder>/local/apache2 --enable-dav --enable-so --enable-maintainer-mode --enable-ssl > make > make install > cd .. # APRをインストール > wget http://ftp.riken.jp/net/apache//apr/apr-1.4.6.tar.gz > tar xfvz apr-1.4.6.tar.gz > cd apr-1.4.6 > ./configure --prefix=/home/<user folder>/local/apache2/ > make > make install > cd .. # APR Utilをインストール > wget http://ftp.meisei-u.ac.jp/mirror/apache/dist//apr/apr-util-1.4.1.tar.gz > tar xvfz apr-util-1.4.1.tar.gz > cd apr-util-1.4.1 > ./configure --prefix=/home/<user folder>/local/apache2/ --with-apr=/home/<user folder>/local/apache2/bin/apr-1-config > make > make install > cd .. # Subversionをインストール > wget http://subversion.tigris.org/downloads/subversion-1.6.17.tar.gz > tar xvfz subversion-1.6.17.tar.gz > cd subversion-1.6.17 > ./configure --prefix=/home/<user folder>/local/apache2/modules --with-apache-libexecdir=/home/<user folder>/local/apache2/ --with-apr=/home/<user folder>/local/apache2/bin/apr-1-config --with-apr-util=/home/<user folder>/local/apache2/bin/apu-1-config --with-apxs=/home/<user folder>/local/apache2/bin/apxs > make > make install
上記、試行錯誤の結果を整理したものなので、抜け等がある可能性がありますがご了承ください。
続いて、Apacheの設定ファイルを編集する:
--- /home/<user folder>/local/apache2/conf/httpd.conf.bak 2012-02-19 08:25:59.000000000 +0900 +++ /home/<user folder>/local/apache2/conf/httpd.conf 2012-02-19 09:01:52.000000000 +0900 @@ -37,7 +37,7 @@ # prevent Apache from glomming onto all bound IP addresses. # #Listen 12.34.56.78:80 -Listen 80 +Listen 8080 @@ -50,7 +50,8 @@ # # Example: # LoadModule foo_module modules/mod_foo.so +LoadModule dav_svn_module modules/mod_dav_svn.so +LoadModule authz_svn_module modules/mod_authz_svn.so # <IfModule !mpm_netware_module> @@ -415,3 +416,13 @@ SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule> + +<Location /svn> + DAV svn + SVNParentPath /home/<user folder>/svn + + AuthType Basic + AuthName "Subversion Authentication" + AuthUserFile /home/<user folder>/local/apache2/conf/svn.repos.passwd + Require valid-user +</Location>
上記設定は、Subversionリポジトリが~/svn以下あり、Basic認証用のパスワードファイルがsvn.repos.passwdと言うファイル名で~/local/apache2/conf以下にあることが前提です。またリポジトリは、認証されたユーザでなければ閲覧・編集できません。
この辺りの詳しい情報は、別の関連サイトをあたって下さい。
以上が完了したら、設定ファイルの構文チェックを行い、サーバをスタートさせる:
> ~/local/apache2/bin/apachectl configtest > ~/local/apache2/bin/apachectl start
Webブラウザや、Subversionクライアントからリポジトリにアクセスし、ログイン・閲覧が問題なくできるか確認する。
さくらレンタルサーバでPython Twistedによるチャットサーバを動かす
***** ご注意 *****
さくらレンタルサーバ内での常駐プロセスの起動は、さくらレンタルサーバの禁止事項で禁止されています。
本記事のプログラムを試される方は、Twistedサーバプログラムの起動は、一時的にして頂きますようお願い致します。
さくらレンタルサーバにSSHでリモートログインし、以下の手順に従って、Python Twistedをインストール:
> bash > mkdir ~/tmp > cd ~/tmp > wget http://twistedmatrix.com/Releases/Twisted/12.0/Twisted-12.0.0.tar.bz2 > tar xvfz Twisted-12.0.0.tar.bz2 > cd Twisted-12.0.0.tar.bz2 > mkdir -p ~/lib/python2.7/site-packages/ > export PYTHONPATH=~/lib/python2.7/site-packages/ > python setup.py install --prefix=~ > echo export PYTHONPATH=~/lib/python2.7/site-packages/ >> ~/.bashrc
最後の一行がないと、次回ログインした際に、Twistedパッケージが見えなくなってしまう。
以下により、無事にインストールできたか確認:
> python >> import twisted >> exit()
これだけでは面白くないので、簡単なTCPサーバを構築してみる。
How To Create A Socket Based iPhone App and Serverを参考に、TCPで動作するチャットサーバを動かしてみる。
この上記チュートリアルはiPhoneアプリとセットになっているが、チャットサーバだけでも試せる。
チュートリアルを基に、server.pyという名前で以下のPythonコードを記述:
from twisted.internet.protocol import Protocol, Factory from twisted.internet import reactor class IphoneChat(Protocol): def connectionMade(self): #self.transport.write("""connected""") self.factory.clients.append(self) print "clients are ", self.factory.clients def connectionLost(self, reason): self.factory.clients.remove(self) def dataReceived(self, data): #print "data is ", data data = data.strip() a = data.split(':') if len(a) > 1: command = a[0] content = a[1] msg = "" if command == "iam": self.name = content msg = self.name + " has joined" elif command == "msg": msg = self.name + ": " + content print msg for c in self.factory.clients: c.message(msg) def message(self, message): self.transport.write(message + '\n') factory = Factory() factory.protocol = IphoneChat factory.clients = [] reactor.listenTCP(8080, factory) print "Iphone Chat server started" reactor.run()
ここで、リッスンポートを80から8080に変更している事に注意。
実装後、以下のコマンドにより、チャットサーバを起動:
> python server.py
Iphone Chat server started
ローカル端末でコンソールを2つ開き、それぞれからtelnetでTCPサーバに接続:
> telnet <TCPサーバURL> 8080 Trying <TCPサーバIPアドレス>... Connected to <TCPサーバURL>. Escape character is '^]'.
それぞれのコンソール(コンソールA/コンソールB)からチャットコマンドを送信すると、TCPサーバを介してチャットが出来る:
・コンソールA
telnet <TCPサーバURL> 8080 Trying <TCPサーバIPアドレス>... Connected to <TCPサーバURL>. Escape character is '^]'. iam:Mike # (1) Mike has joined # (2) Sam has joined # (4) Sam: Hi, Mike! # (6) msg: Hello, Sam!! # (7) Mike: Hello, Sam!! # (8)
・コンソールB
telnet <TCPサーバURL> 8080 Trying <TCPサーバIPアドレス>... Connected to <TCPサーバURL>. Escape character is '^]'. Mike has joined # (2) iam:Sam # (3) Sam has joined # (4) msg:Hi, Mike! # (5) Sam: Hi, Mike! # (6) Mike: Hello, Sam!! # (8)
各コンソール中のコメントの数字は、入出力の順番。それぞれTCPサーバに参加し、互いにメッセージをやり取りできていることが確認できる。
Mac OS X Lionでmacportを使ってBoostをインストールしようとすると、なぜか失敗する
Mac OS X Lionでmacportを使って、
> sudo port install jam > sudo port install boost
とBoostをインストールしようとすると、なぜか以下のエラーが発生する:
:info:activate bzip2: Compressed file ends unexpectedly; :info:activate perhaps it is corrupted? *Possible* reason follows. :info:activate bzip2: Undefined error: 0 :info:activate Input file = /opt/local/var/macports/software/boost/boost-1.48.0_4.darwin_11.x86_64.tbz2, output file = (stdout) :info:activate :info:activate It is possible that the compressed file(s) have become corrupted. :info:activate You can use the -tvv option to test integrity of such files. :info:activate :info:activate You can use the 'bzip2recover' program to attempt to recover :info:activate data from undamaged sections of corrupted files. :info:activate :info:activate :info:activate tar: Truncated tar archive :info:activate tar: Error exit delayed from previous errors. :info:activate shell command "/usr/bin/bzip2 -d -c /opt/local/var/macports/software/boost/boost-1.48.0_4.darwin_11.x86_64.tbz2 | ( /usr/bin/tar -xvpf - )" returned error 1 :error:activate Target org.macports.activate returned: shell command failed (see log for details) :debug:activate Backtrace: shell command failed (see log for details)
ログに描かれているとおり、
> sudo bzip2recover /opt/local/var/macports/software/boost/boost-1.48.0_4.darwin_11.x86_64.tbz2
と実行してから再度インストールを実行しても、結果は変わらず。
そこで、無理矢理な感がある&リビジョン(?)は違うものの、macportのサイトからboost-1.48.0_4.darwin_10.x86_64.tbz2をダウンロードし、これをboost-1.48.0_4.darwin_11.x86_64.tbz2にリネームして、/opt/local/var/macports/software/boost/ディレクトリ下に配置。
再度インストールを実行したら、正しくインストール出来た。
BeagleBoard上のAndroidでWiFiを使う
USB無線LAN子機であるBuffalo WLI-UC-G300Nは、Rowboatをデフォルトの状態でインストールしたBeagleBoard上のAndroidでは認識されない。
利用可能にする為には、子機が利用しているチップセットのベンダのサイトからドライバのソースを取得し、それをBeagleBoard向けにコンパイルして、作成したモジュールをインストールするなど、それなりに手間がかかった。
今回は、この方法についての一連の流れを紹介する。
シリアル通信によりLinuxを監視する
BeagleBoardには、RS232-Cコネクタが搭載されており、ここからRS232-CケーブルでホストPCと接続することにより、ホストPCからAndroidのカーネルであるLinuxのログを監視することが出来るようになる。今回は、その方法を紹介する。
続きを読む