编译安装 Lighttpd 1.4.29,弃用Hiawatha web server 

由于某些原因,我是不打算再用hiawatha了,可是apache httpd这种重量级的web server 我这等小站实在跑不起,而cherokee web server 体积又太大了。

故而只能使用之前不打算用的lighttpd了。下载源码包:
8 wget http://download.lighttpd.net/lighttpd/r ... 29.tar.bz2
9 wget http://nginx.org/download/nginx-1.1.7.tar.gz

移除旧版本:
[root@PowerPC pub]# rm hiawatha*
rm: remove regular file `hiawatha-7.7.tar.gz'? y
[root@PowerPC pub]# rm nginx*
rm: remove regular file `nginx-1.1.6.tar.gz'? y
rm: remove regular file `nginx-1.1.7.tar.gz'? n

移除hiawatha:

find / -name "hiawatha*" -exec rm -rf {} \;


解压源码包,进入目录:
我的configure:
[root@PowerPC lighttpd-1.4.29]# ./configure \
> --prefix=/usr/local/lighttpd \
> --exec-prefix=/usr/local \
> --sysconfdir=/etc/sysconfig/lighttpd \
> --localstatedir=/var \
> --enable-lfs=no \
> --disable-ipv6 \
> --with-mysql=/usr/local/bin/mysql_config \
> --with-ldap \
> --with-attr \
> --with-pcre \
> --with-zlib \
> --with-bzip2

检查依赖,没有问题。给出的编译概况如下:

Plugins:

enabled:
mod_access
mod_accesslog
mod_alias
mod_auth
mod_cgi
mod_compress
mod_dirlisting
mod_evhost
mod_expire
mod_extforward
mod_fastcgi
mod_flv_streaming
mod_indexfile
mod_mysql_vhost
mod_proxy
mod_redirect
mod_rewrite
mod_rrdtool
mod_scgi
mod_secdownload
mod_setenv
mod_simple_vhost
mod_ssi
mod_staticfile
mod_status
mod_trigger_b4_dl
mod_userdir
mod_usertrack
mod_webdav
disabled:
mod_cml
mod_magnet

Features:

enabled:
auth-crypt
auth-ldap
compress-bzip2
compress-deflate
compress-gzip
regex-conditionals
disabled:
large-files
network-ipv6
network-openssl
stat-cache-fam
storage-gdbm
storage-memcache
webdav-locks
webdav-properties


确认后,make && make install 编译安装。

安装完毕后,开始配置lighttpd.在源码包下的doc/config 目录下已经提供了常用的配置文件样例。只需要复制过来,再稍加编辑即可。

主要需要配置的是mysql_vhost_mod 和 fastcgi_mod 两个模块。分别对应conf.d 下的mysql_vhost.conf 和 fastcgi.conf 文件。

当然,首先得在modules.conf 里面把这两个模块载入进来。

先是mysql_vhost_mod,顾名思义,就是把虚拟主机的配置通过数据库(MySQL)来管理。

以root身份登录MySQL,创建新数据库。
create database lighttpd;

新建用户http,并授予读取权限。
grant select on lighttpd.* to 'http'@'localhost' identified by 'PASS';

进入lighttpd数据库,新建一张表,用户存放虚拟主机记录。

mysql> use lighttpd;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> CREATE TABLE domains (
-> domain varchar(64) not null primary key,
-> docroot varchar(128) not null
-> );
Query OK, 0 rows affected (0.01 sec)


接下来,按照虚拟主机的域名和物理路径,依次插入数据。

结果见:
数据库/表列表:

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| bbs |
| blog |
| lighttpd |
| mysql |
| performance_schema |
| vsftpd |
+--------------------+
7 rows in set (0.00 sec)

mysql> show tables;
+--------------------+
| Tables_in_lighttpd |
+--------------------+
| domains |
+--------------------+
1 row in set (0.00 sec)

表结构:

mysql> describe domains;
+---------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| domain | varchar(64) | NO | PRI | NULL | |
| docroot | varchar(128) | NO | | NULL | |
+---------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

表内容:

mysql> select * from domains;
+-------------------------------+-------------------------------------------+
| domain | docroot |
+-------------------------------+-------------------------------------------+
| 18p2p.tk | /home/http/18p2p_tk/ |
| bbs.xiazhengxin.name | /home/http/bbs_xiazhengxin_name/ |
| blog.xiazhengxin.name | /home/http/blog_xiazhengxin_name/ |
| buypc.tk | /home/http/buypc_tk/ |
| chinesepaladin.tk | /home/http/chinesepaladin_tk/ |
| diyit.tk | /home/http/buypc_tk/ |
| diypc.tk | /home/http/buypc_tk/ |
| droid.tk | /home/http/droid_tk/ |
| linux.xiazhengxin.name | /home/http/linux_xiazhengxin_name/ |
| static.xiazhengxin.name | /home/http/static_xiazhengxin_name/ |
| taiwan-is-a-part-of-china.org | /home/http/taiwan-is-a-part-of-china_org/ |
| tibet-is-a-part-of-china.org | /home/http/tibet-is-a-part-of-china_org/ |
| wikileaks.xiazhengxin.name | /home/http/wikileaks_xiazhengxin_name/ |
| xiazhengxin.name | /home/http/blog_xiazhengxin_name/ |
+-------------------------------+-------------------------------------------+
14 rows in set (0.00 sec)


网站物理目录列表:
[root@PowerPC lighttpd]# ls /home/http -lh
总计 44K
drwxrwxr-x 2 http web 4.0K Dec 1 2010 18p2p_tk
drwxrwxr-x 13 http web 4.0K Jul 3 17:52 bbs_xiazhengxin_name
drwxrwxr-x 5 http web 4.0K Jul 3 17:55 blog_xiazhengxin_name
drwxrwxr-x 16 http web 4.0K Mar 27 2011 buypc_tk
drwxrwxr-x 2 http web 4.0K Jul 13 21:44 chinesepaladin_tk
drwxrwxr-x 2 http web 4.0K Apr 21 2011 droid_tk
drwxrwxr-x 12 http web 4.0K May 20 11:47 linux_xiazhengxin_name
drwxrwxr-x 9 http web 4.0K Jul 3 17:06 pma_xiazhengxin_name
drwxrwxr-x 7 http web 4.0K Jun 1 19:35 static_xiazhengxin_name
drwxrwxr-x 2 http web 4.0K Jul 10 00:36 taiwan-is-a-part-of-china_org
drwxrwxr-x 2 http web 4.0K Dec 21 2010 wikileaks_xiazhengxin_name

之后,就是在mysql_vhost_mod 里面设置好访问数据库的库名、地址、端口、用户名、密码、查询语句即可。见下:

mysql-vhost.db = "lighttpd"
mysql-vhost.user = "http"
mysql-vhost.pass = "PASS"
mysql-vhost.sock = "/tmp/mysqld.sock"
mysql-vhost.sql = "SELECT docroot FROM domains WHERE domain='?';"
mysql-vhost.hostname = "localhost"
mysql-vhost.port = 3306


至此,mysql_vhost_mod 结束。下面是fastcgi_mod.

这个其实和nginx差不多,指明cgi的地址、端口、扩展名即可。
我的如下:

fastcgi.server = (
".php" =>
( "localhost" =>
(
"socket" => "/tmp/php.sock" # 我用的套接字,与地址+端口一致
)
)
)


一切完毕之后,启动lighttpd.
lighttpd -f /etc/sysconfig/lighttpd/lighttpd.conf

至此,安装成功。
还有,本来想顺带升级下nginx的,由于有事,只好作罢~

注:
本文在撰写、实践时参考了以下文档:
http://redmine.lighttpd.net/wiki/lightt ... ionOptions
http://redmine.lighttpd.net/wiki/lightt ... MySQLVhost
http://redmine.lighttpd.net/wiki/lightt ... ModFastCGI

此外,lighttpd 版本信息如下:
[root@PowerPC lighttpd]# lighttpd -V
lighttpd/1.4.29 - a light and fast webserver
Build-Date: Nov 5 2011 23:25:18

Event Handlers:

+ select (generic)
+ poll (Unix)
- rt-signals (Linux 2.4+)
+ epoll (Linux 2.6)
- /dev/poll (Solaris)
- eventports (Solaris)
- kqueue (FreeBSD)
- libev (generic)

Network handler:

+ sendfile

Features:

- IPv6 support
+ zlib support
+ bzip2 support
+ crypt support
- SSL Support
+ PCRE support
+ mySQL support
+ LDAP support
- memcached support
- FAM support
- LUA support
- xml support
- SQLite support
- GDBM support
[ ] ( 2437 次浏览 ) 永久链接 ( 3 / 2853 )

<< <上一页 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 下一页> >>