---
title: "在debian4上搭建一个lighttpd+fastcgi+php5+mysql环境"
author: "darwinux"
date: "2008-08-28T00:07:00Z"
tags: ["Debian", "MySQL", "Office", "PHP", "lighttpd"]
categories: ["操作系统"]
slug: "debian4-lighttpd-fastcgi-php5-mysql"
draft: false
lastmod: "2011-05-09T11:48:18Z"
id: 1037295
url: "https://darwinux.iteye.com/blog/1037295"
---

最近兴致来了，想法在 debian 下搭建某 php 论坛，，或者作为服务器上的补充。。所以，这几天的工作就孕育了这篇工作笔记，暂且把 gentoo 的后续先搁置一下，并不是不准备继续，只是稍微转换，以免头晕 J

话说回来，如果是用 2 个相同 IDE 硬盘来搞的话，搞个 raid+lvm 仍然是不错的选择，速度和稳定都有较大的提升，因为我这是利用我公司的未处理垃圾来搭建，配置都是古董： C633 ， SDR128M ， 15Ghd.. （真是有够寒酸了）

废话不多说了，开始吧！用在官方下载的 dibian netinstall 的安装 CD 刻成的 disc ，引导系统，然后怎么装。。不废话了，，我按

/boot 128M ext2

Swap 256M

/ 全部给他 ext3

格式分好区后，建议不要直接就连上网线，马上更新，，因为你的网络不一定很快，就算快，你连 cn99 的速度也不是很快，所以还是装好基本系统，重启吧。我又要说句题外话了。。如果你仔细看了我写的 gentoo 笔记的话，就会觉得，其实搭建 raid+lvm 超容易，，所以说啊， gentoo 是学习 linux 的好物 ~~~

继续。。装好了的 debian 首先换源 :nano –w /etc/apt/sources.list （现在习惯用 nano 了。。 gentoo 的习惯。。。）我这电信以前连 cn99 爆快。。现在根本连 ADSL 都不如。。换吧，我这换成了 ustc 的源，很不错，我把完整的 ustc 源贴出来，大家注意看吧，因为我发现很多网上找到关于 ustc ， cn99 的源都不是很完整。。

deb http://debian.ustc.edu.cn/debian stable main non-free contrib&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;

 

deb-src http://debian.ustc.edu.cn/debian stable main non-free contrib

 

 

 

 

deb http://debian.ustc.edu.cn/debian proposed-updates main contrib non-free

 

deb-src http://debian.ustc.edu.cn/debian proposed-updates main contrib non-free

 

 

 

 

deb http://debian.ustc.edu.cn/debian-security stable/updates main

用上面的源，更新： aptitude update;aptitude upgrade;OK ，更新完成，我在附带说句， debian,ubuntu 如果发现系统时间不是很正常的话，，就是距标准时间差入比较大的话，会有 GPG 的错误，只要用 date 命令改回正常时间就好了。

更新完以后，我们开始搭建环境：

Aptitude install lighttpd mysql-server php5-cgi php5-mysql

等一下下，都下载安装好了以后，配置下这些东西：

配置 php:

修改 /etc/php5/cgi/php.ini ，在其末尾添加：

cgi.fix\_pathinfo=1

配置 lighttp:

修改 /etc/lighttpd/lighttpd.conf, 先给 server.modules 增加 mod\_fastcgi ，如下：

server.modules = (

 

“mod\_access”,

 

“mod\_alias”,

 

“mod\_accesslog”,

 

“mod\_fastcgi”,

 

“mod\_rewrite”,

 

)

然后调转到该文件的末尾，加上：

fastcgi.server = ( “.php” =&gt; ((

 

“bin-path” =&gt; “/usr/bin/php5-cgi”,

 

“socket” =&gt; “/tmp/php.socket”

 

)))

接着在修改 mysql 的默认密码： mysqladmin –u root password &lt; 你设置的密码 &gt; ，然后恭喜你，一个基本的 lighttpd+fastcgi+php5+mysql 的环境就搭建好了 J

在补个虚拟目录的设置，这个要补上，仍然是打开 /etc/lighttpd/lighttpd.conf, 在 #virtual 那行的下面可以添加自己需要的虚拟目录：（我做个例子）

Alias.url=(“/bbs/”=&gt;”/var/www/bbs/”) lighttpd 默认的 web 目录在 /var/www/ 下。。顺便提醒一下大家，目录的权限。。一般的话最好只启用最低的权限，，，安全第一。。

这里还补一下，刚才前面忘记写的一个内容。。。就是安装的时候没配置网络，安装好 debian 后，要先配置网络才能 aptitude 。。。

编辑 /etc/network/interfaces 文件：在后面加入：

auto eth0

 

iface eth0 inet dhcp

我这仍然是 dhcp = = , 很方遍

恩，基本上来说， debian 下这个环境是搭建好了，大家可以自己在搞个 vsftpd ，这样就可以上传文件了。。这个的话也很简单，大家只要注意上传文件的权限就没什么了。

还是老套路，今天就到这里了。。。再见 ~~