centos下lighttpd web.py环境安装及使用
2014-08-14 00:00
489 查看
摘要: 系统:centos 5.2 python2.4.3, 以 ">" 开头是你要运行的命令, 以 "*" 为注解
以 ">" 开头是你要运行的命令
以 "*" 为注解
系统:centos 5.2 python2.4.3
Step 1: 系统用户 为lighttpd准备
> groupadd -g 80 www
> useradd -g 80 -u 80 -M -s /sbin/nologin www
* -M 不建用户目录
* -s 不能使用shell
Step 2: centos 下安装必要的包
> yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel bzip2 bzip2-devel make autoconf
* pcre 正规表达式
* bzip & zlib 压缩
* make & autoconf 编译安装
Step 3: lighttpd 安装
> wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.26.tar.gz
> tar -zxvf lighttpd-1.4.26.tar.gz
> cd lighttpd-1.4.24
> ./configure && make && make install
> cp doc/rc.lighttpd.redhat /etc/init.d/lighttpd
> cp doc/lighttpd.conf /usr/local/lighttpd.conf
> vim /etc/init.d/lighttpd
* 修改 /usr/sbin/lighttpd 为 /usr/local/sbin/lighttpd
* 修改 /etc/lighttpd/lighttpd 为 /usr/local/etc/lighttpd.conf
执行
> /etc/init.d/lighttpd start
这时访问你的ip有404页面
step 4: web.py安装
*下载 ez_setup.py
> cd ~
> wget peak.telecommunity.com/dist/ez_setup.py
> python ez_setup.py
*执行上条命令后将安装easy_install工具
> easy_install web.py & flup
自动安装web.py 和 flup
* flup传闻是fastcgi的python实理接口类的东东
测试程序:
> vim /home/web/code.py
内容:
#!/usr/bin/env python
import web
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())
class hello:
def GET(self, name):
if not name:
name = 'World'
return 'Hello, ' + name + '!'
if __name__ == "__main__":
app.run()
* 第一行 #!/usr/local/env python 不能少
修改 /usr/local/etc/lighttpd.conf 配置文件
打开 mod_fastcgi 和 mod_rewrite 两个模块
server.document-root = "/home/web/"
fastcgi.server = ( "/code.py" =>
(( "socket" => "/tmp/fastcgi.socket",
"bin-path" => "/home/web/code.py",
"max-procs" => 1
))
)
url.rewrite-once = (
"^/favicon.ico$" => "/static/favicon.ico",
"^/static/(.*)$" => "/static/$1",
"^/(.*)$" => "/code.py/$1"
)
> /etc/init.d/lighttpd restart
重启lighttpd即可
以 ">" 开头是你要运行的命令
以 "*" 为注解
系统:centos 5.2 python2.4.3
Step 1: 系统用户 为lighttpd准备
> groupadd -g 80 www
> useradd -g 80 -u 80 -M -s /sbin/nologin www
* -M 不建用户目录
* -s 不能使用shell
Step 2: centos 下安装必要的包
> yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel bzip2 bzip2-devel make autoconf
* pcre 正规表达式
* bzip & zlib 压缩
* make & autoconf 编译安装
Step 3: lighttpd 安装
> wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.26.tar.gz
> tar -zxvf lighttpd-1.4.26.tar.gz
> cd lighttpd-1.4.24
> ./configure && make && make install
> cp doc/rc.lighttpd.redhat /etc/init.d/lighttpd
> cp doc/lighttpd.conf /usr/local/lighttpd.conf
> vim /etc/init.d/lighttpd
* 修改 /usr/sbin/lighttpd 为 /usr/local/sbin/lighttpd
* 修改 /etc/lighttpd/lighttpd 为 /usr/local/etc/lighttpd.conf
执行
> /etc/init.d/lighttpd start
这时访问你的ip有404页面
step 4: web.py安装
*下载 ez_setup.py
> cd ~
> wget peak.telecommunity.com/dist/ez_setup.py
> python ez_setup.py
*执行上条命令后将安装easy_install工具
> easy_install web.py & flup
自动安装web.py 和 flup
* flup传闻是fastcgi的python实理接口类的东东
测试程序:
> vim /home/web/code.py
内容:
#!/usr/bin/env python
import web
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())
class hello:
def GET(self, name):
if not name:
name = 'World'
return 'Hello, ' + name + '!'
if __name__ == "__main__":
app.run()
* 第一行 #!/usr/local/env python 不能少
修改 /usr/local/etc/lighttpd.conf 配置文件
打开 mod_fastcgi 和 mod_rewrite 两个模块
server.document-root = "/home/web/"
fastcgi.server = ( "/code.py" =>
(( "socket" => "/tmp/fastcgi.socket",
"bin-path" => "/home/web/code.py",
"max-procs" => 1
))
)
url.rewrite-once = (
"^/favicon.ico$" => "/static/favicon.ico",
"^/static/(.*)$" => "/static/$1",
"^/(.*)$" => "/code.py/$1"
)
> /etc/init.d/lighttpd restart
重启lighttpd即可
相关文章推荐
- 手把手教你在centos下编译安装配置高性能web服务器环境nginx+php(fast-cgi)+mysql等/适合小内存vps使用
- 手把手教你在centos下编译安装配置高性能web服务器环境nginx+php(fast-cgi)+mysql等/适合小内存vps使用
- 使用PuTTy在CentOS下安装web.py与简单的文件传输
- 使用LNMP一键安装包配置CentOS服务器环境教程
- Memcached在CentOS环境中的安装使用及Xmemcached客户端的使用
- 搭建Web服务器之Step6:CentOS6.3安装JDK和环境配置
- CentOS 6下,远程安装KVM虚拟机,并使用apache mod_proxy反向代理建立多个web服务器
- 搭建PXE全自动系统安装配置环境(分别使用CentOS和Ubuntu做安装源)
- CentOS下Lighttpd Web服务器安装与配置方法
- CentOS使用YUM安装php运行环境,包含php,php-fpm,nginx,mysql
- CentOS中使用yum安装php环境
- Java Web Service eclipse安装 环境 使用命令
- CentOS 5.5使用yum来安装LAMP(php运行环境)(转)
- CentOS 6.4 i386 版本安装 FastDFS、使用Nginx作为文件访问WEB服务器
- Python2.6+WSGI+web.py 构建WEB环境(CentOS5.4)
- 在CentOS 5.6中使用源码安装lighttpd
- lighttpd+webpy安装实践
- CentOS 5.5使用yum来安装LAMP(php运行环境)
- centos下使用yum安装jdk java环境安装 activeMQ运行环境 tomcat安装
- NTP的安装配置和使用(在centos6.4_x86_64环境下)