개발/python
ubuntu에서 mod_python 간단히 체험해보기.
Dsp
2008. 4. 2. 13:00
ubuntu에서 설치는 synaptic을 이용해서 간단하게 설치가능하니 생략하고...
mod_python을 설치한 후에 enable 시키려면,
/etc/apache2/mods-enabled 폴더에 symbolic link 를 다음과 같이 건다.
mod_python.load -> ../mods-available/mod_python.load
또한 httpd.conf , 혹은 다른 conf file에 다음과 같이 python handler를 지정한다.
다음과 같이 지정된 경로에 test.py 파일을 생성한다.
그리고 apache를 재시작한 후,
이제, 사이트에 접속해 보면 된다.
http://localhost/python/test.py
혹시 php, perl에는 익숙하고 python은 잘 모른다면,
아래 사이트가 유용할 것이다.
http://qna.nu/w/cs/?python=on&php=on&perl=on
mod_python을 설치한 후에 enable 시키려면,
/etc/apache2/mods-enabled 폴더에 symbolic link 를 다음과 같이 건다.
mod_python.load -> ../mods-available/mod_python.load
또한 httpd.conf , 혹은 다른 conf file에 다음과 같이 python handler를 지정한다.
<Directory "/python코드의패쓰">
AddHandler python-program .py
PythonHandler test
PythonDebug on
</Directory>
AddHandler python-program .py
PythonHandler test
PythonDebug on
</Directory>
다음과 같이 지정된 경로에 test.py 파일을 생성한다.
from mod_python import apache
def handler(req):
req.content_type="Text/Plain"
req.send_http_header()
req.write("This is a test page...")
return apache.OK
def handler(req):
req.content_type="Text/Plain"
req.send_http_header()
req.write("This is a test page...")
return apache.OK
그리고 apache를 재시작한 후,
sudo /etc/init.d/apache2 restart
이제, 사이트에 접속해 보면 된다.
http://localhost/python/test.py
혹시 php, perl에는 익숙하고 python은 잘 모른다면,
아래 사이트가 유용할 것이다.
http://qna.nu/w/cs/?python=on&php=on&perl=on