UbuntuにPythonの開発環境を構築する
ぐぐってみたら、taskselというコマンドでLAMP環境を構築できるらしい。
LAMP 環境の設定 - Linux 入門
このサイトの手順どおりにターミナルで入力。
- Taskselをインストールする
- TaskselからLAMP環境をインストール
- libapache2-mod-python をインストールして、そしてそれを有効化
- /etc/apache2/sites-available/defaultを編集する.
- /var/www/test.pyを作成
- Apacheの再起動
- ブラウザで確認
$sudo apt-get install tasksel
$sudo taskselinstall lamp-server
すると画面が切り替わる。その際に MySQLのrootに対してのパスワードを求められるので、入力(しなくてもよい?)
$sudo apt-get install libapache2-mod-python
ここ以降の作業は以下のサイトを参考にして行った。(上記サイトではできなかったので)
SREngine: Sein blog: 【Ubuntu】 apt-getでインストールした場合のLAMP (Python)の設定
httd.confでの直接編集は行わないとのこと。
$sudo vi /etc/apache2/sites-available/default
/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>
def index(req): return "Hello, Python!"
$sudo /etc/init.d/apache2 restart
これで大丈夫かと思われる