ラベル Lion 10.7.3(11D50) の投稿を表示しています。 すべての投稿を表示
ラベル Lion 10.7.3(11D50) の投稿を表示しています。 すべての投稿を表示

2012-02-18

「Lion10.7の標準Apache2」にmod_wsgiをインストール

以前の記事『図書紹介#010:「WSGIウェブプログラミング」』で、wsgi-moduleのコンパイルまでテストできたが、この本はWindowsで、Apacheも新規にインストールする話で、Macの場合は説明が無い。

そこで、以前から気になっていた「Mac OS X でのApache2」の設定を調べた記事が『「Lion10.7の標準Apache2」での設定状況 』です。これらを元にしてwsgi_mod/3.3をApache/2.2.21にインストールした結果をまとめて置きます。

「WSGIウェブプログラミング」 p76の「リスト4.4 http-wsgi.conf(Windows版)」を参考にして、「/usr/apache2/extr/」にhttp-wsgi.conf(OSX版)を追加した;

div-mm:/etc/apache2/extra u1$ ll
total 24
-rw-r--r--  1 root  wheel   2841  9 18 15:47 httpd-autoindex.conf
-rw-r--r--  1 root  wheel   1648  9 18 15:47 httpd-dav.conf
-rw-r--r--  1 root  wheel   2344  9 18 15:47 httpd-default.conf
-rw-r--r--  1 root  wheel   1103  9 18 15:47 httpd-info.conf
-rw-r--r--  1 root  wheel   5078  9 18 15:47 httpd-languages.conf
-rw-r--r--  1 root  wheel    942  9 18 15:47 httpd-manual.conf
-rw-r--r--  1 root  wheel   4074  9 18 15:47 httpd-mpm.conf
-rw-r--r--  1 root  wheel   2180  9 18 15:47 httpd-multilang-errordoc.conf
-rw-r--r--  1 root  wheel  10249  9 18 15:47 httpd-ssl.conf
-rw-r--r--  1 root  wheel    514  9 18 15:47 httpd-userdir.conf
-rw-r--r--  1 root  wheel   1545  9 18 15:47 httpd-vhosts.conf
-rw-r--r--  1 root  wheel    593  2 17 21:12 httpd-wsgi.conf
div-mm:/etc/apache2/extra u1$
その内容は;
div-mm:/etc/apache2/extra u1$ cat httpd-wsgi.conf
#
# refer to "WSGI Programming", p74..6. 
# by u1 at div-mm on Lion 10.7.3, 2011-02-17.
## Home BU: ~/Sites/myApache2/apache2_BU/httpd-wsgi.conf
## Apache2: /private/etc/apache2/extra/httpd-wsgi.conf
#
LoadModule wsgi_module libexec/apache2/mod_wsgi.so

Listen 9000

<VirtualHost *:9000>
    ErrorLog "/private/var/log/apache2/wsgi-error_log"
    CustomLog "/private/var/log/apache2/wsgi-access_log" common
</VirtualHost>

<Directory "/Users/u1/Sites/devP/application/wsgi">
    Order deny,allow
    Allow from all
</Directory>

WSGIScriptAlias /wsgi "/Users/u1/Sites/devP/application/wsgi"
div-mm:/etc/apache2/extra u1$ 
です。このファイルを「/etc/apache2/http.conf」の中でインクルードしました;
 # Language settings
Include /private/etc/apache2/extra/httpd-languages.conf

<IfDefine WEBSHARING_ON>
# Multi    -language error messages
#Include /private/etc/apache2/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
Include /private/etc/apache2/extra/httpd-autoindex.conf

# User home directories
Include /private/etc/apache2/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include /private/etc/apache2/extra/httpd-info.conf

# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
Include /private/etc/apache2/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include /private/etc/apache2/extra/httpd-dav.conf

# wsgi(Web Server Gateway Interface) between Apache2 and web-applications
Include "/private/etc/apache2/extra/httpd-wsgi.conf"

</IfDefine>
どこに置くのがいいのか判らないので、見慣れた「httpd-manual.conf
」の近くに入れてみました。

 テストの為に、「WSGIウェブプログラミング」p80、index.wsgiを作り;
div-mm:~/Sites/devP/application/wsgi u1$ cat index.wsgi
# -*- coding: utf-8 -*-

def application(environ, start_response):

    status = '200 OK'
    body = 'wsgi Application のテスト'
    header = [('Content-Type', 'text/html; charset=-8'),
           ('Content-Length', str(len(body)))]
    start_response(status, header)
    return [body]
div-mm:~/Sites/devP/application/wsgi u1$ 


ブラウザから「http//:localhost:9000/wsgi/index.wsgi」にアクセスすると、 「wsgi Application のテスト」が表示された。


なお、wsgiのログは、「コンソール.app」で確認できた。

小技:Apacheのヴァージョンを得るには;
div-mm:~ u1$ httpd -v
Server version: Apache/2.2.21 (Unix)
Server built:   Nov 15 2011 15:12:57
div-mm:~ u1$ 


ーーーー このポストの履歴
  1. 開始 2012-02-18 (土) 14:00
  2. 追加 2012-02-19  (日) 18:03  ヴァージョンを得る

2012-02-15

llvm-gccとgccと

PythonやRubyの環境を整えようと思うと、「llvm-gccとgccとの違い」が気になってきました。その中で、
と言うサイトは、参考になりそうです。が、私の所
とは;
  • Mac mini(mid 2011)
  • Lion 10.7.3(11D50)
  • Xcode 4.1(4B110)
と微妙に違うので、比較の為には自分の情報を整理してみる必要がありそうです。

「/usr/bin」でのgcc関連を調べてみた;

div-mm:/usr/bin u1$ lla |grep gcc
lrwxr-xr-x     1 root   wheel        12 10  1 11:49 cc@ -> llvm-gcc-4.2
lrwxr-xr-x     1 root   wheel        12 10  1 11:49 gcc@ -> llvm-gcc-4.2
-rwxr-xr-x     1 root   wheel    113024  5 16  2011 gcc-4.2*
-rwxr-xr-x     1 root   wheel    562992  5 16  2011 i686-apple-darwin11-gcc-4.2.1*
lrwxr-xr-x     1 root   admin        52 10  1 11:48 i686-apple-darwin11-llvm-g++-4.2@ -> ../llvm-gcc-4.2/bin/i686-apple-darwin11-llvm-g++-4.2
lrwxr-xr-x     1 root   admin        52 10  1 11:48 i686-apple-darwin11-llvm-gcc-4.2@ -> ../llvm-gcc-4.2/bin/i686-apple-darwin11-llvm-gcc-4.2
lrwxr-xr-x     1 root   admin        32 10  1 11:48 llvm-cpp-4.2@ -> ../llvm-gcc-4.2/bin/llvm-cpp-4.2
lrwxr-xr-x     1 root   admin        32 10  1 11:48 llvm-g++@ -> ../llvm-gcc-4.2/bin/llvm-g++-4.2
lrwxr-xr-x     1 root   admin        32 10  1 11:48 llvm-g++-4.2@ -> ../llvm-gcc-4.2/bin/llvm-g++-4.2
lrwxr-xr-x     1 root   admin        32 10  1 11:48 llvm-gcc@ -> ../llvm-gcc-4.2/bin/llvm-gcc-4.2
lrwxr-xr-x     1 root   admin        32 10  1 11:48 llvm-gcc-4.2@ -> ../llvm-gcc-4.2/bin/llvm-gcc-4.2
div-mm:/usr/bin u1$ 

このように、自分のLionでは、gcc-4.2もllvm-gccも存在している。けれど、gccはllvm-gccにシンボリック・リンクされている。gcc-4.2が存在するのは、Xcode4.1で留めているからそうなっているのかもしれない。従って、
  • Xcode4.2に上げても、gcc-4.2を上記サイトを参考にインストールすれば良いだけかもしれない。
  • Lion10.7.3では強い障害が起る場合が散見するが、自分の所はあまり大事はおこっていないのは、gcc-4.2があるお陰か???
    • 小さな障害として、Docのアイコンを右クリックしてオプションから
      • 「このデスクトップ 」→ 固定成功。
      • 「すべてのデスクトップ」→ 開いたデスクトップに固定されて、駄目。
なお、直接にヴァージョン情報を見てみたら;

div-mm:~ u1$ gcc-4.2 --version
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

div-mm:~ u1$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

div-mm:~ u1$ 

参考の為に、IMac(late 2009)で、「Snow Leopard 10.6.8」についても調べてみた;

curl:~ u1$ lla /usr/bin/ |grep gcc
lrwxr-xr-x     1 root   wheel           7  7 22  2011 cc@ -> gcc-4.2
lrwxr-xr-x     1 root   wheel           7  7 22  2011 gcc@ -> gcc-4.2
-rwxr-xr-x     1 root   wheel       97392 10 24  2010 gcc-4.0*
-rwxr-xr-x     1 root   wheel      166128 10 24  2010 gcc-4.2*
-rwxr-xr-x     1 root   wheel      369696 10 24  2010 i686-apple-darwin10-gcc-4.0.1*
-rwxr-xr-x     1 root   wheel      816560 10 24  2010 i686-apple-darwin10-gcc-4.2.1*
lrwxr-xr-x     1 root   admin          52  7 22  2011 i686-apple-darwin10-llvm-g++-4.2@ -> ../llvm-gcc-4.2/bin/i686-apple-darwin10-llvm-g++-4.2
lrwxr-xr-x     1 root   admin          52  7 22  2011 i686-apple-darwin10-llvm-gcc-4.2@ -> ../llvm-gcc-4.2/bin/i686-apple-darwin10-llvm-gcc-4.2
lrwxr-xr-x     1 root   admin          32  7 22  2011 llvm-cpp-4.2@ -> ../llvm-gcc-4.2/bin/llvm-cpp-4.2
lrwxr-xr-x     1 root   admin          32  7 22  2011 llvm-g++@ -> ../llvm-gcc-4.2/bin/llvm-g++-4.2
lrwxr-xr-x     1 root   admin          32  7 22  2011 llvm-g++-4.2@ -> ../llvm-gcc-4.2/bin/llvm-g++-4.2
lrwxr-xr-x     1 root   admin          32  7 22  2011 llvm-gcc@ -> ../llvm-gcc-4.2/bin/llvm-gcc-4.2
lrwxr-xr-x     1 root   admin          32  7 22  2011 llvm-gcc-4.2@ -> ../llvm-gcc-4.2/bin/llvm-gcc-4.2
-rwxr-xr-x     1 root   wheel      373792 10 24  2010 powerpc-apple-darwin10-gcc-4.0.1*
-rwxr-xr-x     1 root   wheel      820496 10 24  2010 powerpc-apple-darwin10-gcc-4.2.1*
lrwxr-xr-x     1 root   admin          55  7 22  2011 powerpc-apple-darwin10-llvm-g++-4.2@ -> ../llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-g++-4.2
lrwxr-xr-x     1 root   admin          55  7 22  2011 powerpc-apple-darwin10-llvm-gcc-4.2@ -> ../llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-gcc-4.2
curl:~ u1$ 
 

確かに雪豹ではgccはgcc-4.2にシンボリック・リンクされている。 llvm-gcc-4.2も在るが、gcc-4.0もまだあるようだ。

Wikipediaで調べてみると、LLVM → Clang;
と言う伸展があるらしい。そこでターミナルを叩くと;

div-mm:~ u1$ which clang
/usr/bin/clang
div-mm:~ u1$ man clang
div-mm:~ u1$ clang --version
Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.3.0
Thread model: posix
div-mm:~ u1$ ll /usr/bin/ |grep clang
-rwxrwxr-x    1 root   admin  39612800  6 22  2011 clang*
lrwxr-xr-x    1 root   admin         5 10  1 11:48 clang++@ -> clang
div-mm:~ u1$ 
 なんと「巨大なclang」が既に実装されているようだ。全然理解できていないが、面白そうだなぁ。


ーーーー このポストの履歴
  1. 開始 2012-02-15 (水) 18:39
  2. 追加 2012-02-16  (木) 13:05  「巨大なclang」

注目の投稿

Terminalでの、なんちゃってViモドキ

近頃、ようやくKarabiner-Elementsに慣れてきたので、 Terminalで動作する「擬似Vi-Mode」を作って見たので、ご紹介します。 『概要』 「擬似Vi-Mode」の所以は、方向キー「←↓↑→」を通常の「hjkl」ではなくて「jkil」としました。これ...