Ross Wan's World!

Python, Ajax, PHP and Linux.

Archlinux: 以 non-root 运行 Lighttpd

Posted by Ross Wan 于 2008/11/07

假设 arch 为系统已经存在的非管理员账户(non-root)和组。

$ groups

可以查看用户 arch 是否已经加入 arch 组。

所用软件版本: PHP 5.2.6,Lighttpd 1.4.20。

安装 Lighttpd、PHP、Fastcgi

# pacman -S lighttpd php fcgi

配置 PHP

修改 /etc/php/php.ini,去掉以下行前面的注释:

open_basedir = /home/:/tmp/:/usr/share/pear/

配置 Lighttpd

修改 /etc/lighttpd/lighttpd.conf 文件,注释或者添加以下行:

server.document-root    = "/home/arch/http/www/"

server.modules    = (

fastcgi.server    = ( ".php" =>
                           ( "localhost" =>
                               "socket" => "/tmp/php-fastcgi.socket",
                               "bin-path" => "/usr/bin/php-cgi"

server.username   = "arch"
server.groupname    = "arch"

注: server.document-root 是设置文档根目录,方便 arch 用户来管理。


# chown arch arch /var/log/lighttpd/*.log

修改 /etc/logrotate.d/lighttpd,在第二行添加 create 644 arch arch,示例:

/var/log/lighttpd/*log {
     create 644 arch arch
       /bin/kill -HUP `cat /var/run/lighttpd/ 2>/dev/null` 2> /dev/null || true

运行 Lighttpd

在 /home/arch/http/www/ 下创建 index.php 文件:


启动 Lighttpd daemon:

# /etc/rc.d/lighttpd start

在浏览器里打开 http://localhost/。如果配置成功的话,会显示正确的 PHP 信息。



Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: