Ubuntu12.10下安装lighttpd1.4.32详细步骤

    最近在自学Python,学到Web开发,自然就接触到Python的Web框架,Django 很出色,但是个人喜欢精简核框架,找到web.py(http://webpy.org/)。网上搜了一下web.py资料很少,只能跑到官网上自学。开发首先要把环境搭建好,虽然web.py内置一个web服务器,但是官网还是推荐用 lighttpd 或者Apache。 下面详细介绍自己安装lighttpd的过错中出现的问题和解决方法。

    首先我们先从lighttpd官网上下载http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.32.tar.gz 

    解压后 lighttpd-1.4.32 进入解压后的目录  cd  xxx/lighttpd-1.4.32/

    

1 ./configure

    这里就出错啦。具体错误代码忘记保存啦。但是 是缺少 pcre 。到 http://www.pcre.org/ 活在 https://sourceforge.net/projects/pcre/files/pcre/ 上下载 解压 安装

进入到pcre解压后的目录

./configure

           这里有出现错误啦。缺少C++编译器。我们只要安装G++就可以啦

1 sudo apt-get install g++

          安装完之后,在重新编译pcre

1 ./configure
2 make

    pcre安装成功之后就可以重新编译安装 lighttpd 了

   另外的错误提示一并贴一下
    出现configure: error: C compiler cannot create executables …   安装sudo apt-get install libc6-dev.
    出现configure: error: configure: error: pcre-config not found …     安装sudo apt-get install libpcre3-dev
    出现configure: error: zlib-headers and/or libs where not found …    安装sudo apt-get install zlib1g-dev
    出现configure: error: bzip2-headers and/or libs where not found … 安装sudo apt-get install libbz2-dev

         最后有跑到 lighttpd 官网看了下 安装步骤,才发现更简单,直接输入下面指令

1 sudo apt-get build-dep lighttpd
2 ./configure
3 make
4 su make install

        默认是安装在 /usr/local  如果你想安装在其他目录,输入

1 ./configure --help

       里面有详细说明

        

       安装成功后要想在控制台中 直接启动 lighttpd  需要创建初始化脚本 ,输入

1 sudo update-rc.d lighttpd defaults

     我的机器 提示  System start/stop links for /etc/init.d/lighttpd already exist。看来在安装的时候 已经帮我创建好了。

     启动 lighttpd

1 lighttpd -f

  lighttpd: option requires an argument -- 'f'
  lighttpd/1.4.32 (Jan 13 2013 12:44:00) - a light and fast webserver
  usage:
    -f <name> filename of the config-file
    -m <name> module directory (default: /usr/local/lib)
    -p print the parsed config-file in internal form, and exit
    -t test the config-file, and exit
    -D don't go to background (default: go to background)
    -v show version
    -V show compile-time features  
    -h show this help

    看来我们从配置文件启动,输入指令

1 sudo lighttpd -f /etc/lighttpd/lighttpd.conf 

     我的机器上提示  2013-01-13 14:36:08: (network.c.379) can't bind to port:  80 Address already in use 

     我的80端口被Apache服务器占用了,所以我们要修改配置文件

vi /etc/lighttpd/lighttpd.conf

      加上

    server.port                = 8090  ##设置端口

   保存退出 ,输入指令

1 sudo lighttpd -f /etc/lighttpd/lighttpd.conf

  启动 lighttpd 服务器

  浏览器中输入

   localhost:8080   /默认访问的是 /var/www/ 目录

  lighttpd.conf 的详细配置 参考

 http://hi.baidu.com/uybdifnwhtbhqsd/item/ed1b59eb7b7560265a2d6497

  其实 lighttpd 的配置文件 还是 非常 清晰明了的。

原文地址:https://www.cnblogs.com/ArtsCrafts/p/lighttpd.html