2008年3月8日土曜日

【Ubuntu】 apt-getでインストールした場合のLAMP (Python)の設定

【Ubuntu】 LAMP (Linux, Apache2, MySQL, Python一発インストールのつづき。

apt-getでインストールした場合はhttpd.confを直接編集しない。
/etc/apache2/sites-available/defaultを編集する.

cd /etc/apache2/sites-available/
sudo gedit default


<Directory /var/www/>を以下に変更する.


<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny
allow from all

AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On

# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>



テストスクリプト/var/www/test.pyを編集する(sudo gedit /var/www/test.py).


def index(req):
return "Test successful"



Apache再起動。

# sudo /etc/init.d/apache2 restart


ブラウザで
http://localhost/test.py
にアクセスして確認する.

PythonとMySQLの接続方法は
【Python】 MySQL-pythonのインストール
を参考に。

ラベル: , , , ,

0 件のコメント:

コメントを投稿

登録 コメントの投稿 [Atom]

この投稿へのリンク:

リンクを作成

<< ホーム