一、安装lighttpd
1、解压lighttpd
tar xzvf lighttpd-1.4.58.tar.gz
./configure --prefix=/usr/local/lighttpd
make;make install
2、在安装目录下创建两个文件夹,conf文件夹存放lighttpd配置文件,log文件夹存放日志文件
```java
mkdir /usr/local/lighttpd/conf
mkdir /usr/local/lighttpd/log
```
3、将源码中自带的配置文件放至刚创建的conf文件夹内,配置文件根据实际需要修改。
```java
cp doc/config/lighttpd.conf /usr/local/lighttpd/conf/
cp doc/config/modules.conf /usr/local/lighttpd/conf/
cp doc/config/conf.d/ /usr/local/lighttpd/confg/ -r
```
4、将spawn-php. sh脚本拷贝至lighttpd安装目录(bin目录自行创建)
```java
cp doc/scripts/spawn-php.sh /usr/local/lighttpd/bin
```
spawn-php. sh需要修改,见下文。
二、安装PHP
1、先安装libxml2库
```java
tar xzvf libxml2-2.7.2.tar.gz
cd libxml2-2.7.2
./configure
make;make install
```
注:如果是arm架构服务器,. /configure --build=arm
2、解压PHP源码
```java
tar xzvf php-5.4.45.tar.gz
cd php-5.4.45
. /configure --prefix=/usr/local/php-fcgi --enable-fastcgi --enable-zend-multibyte --with-config-file-path=/etc --enable-discard-path --enable-force-cgi-redirect
//将源码中自带的php.ini拷贝至/etc下
cp php.ini-production /etc/php.ini
make;make install
```
注:arm架构需要添加参数:--build=arm
三、安装spawn-fcgi
```java
tar xzvf spawn-fcgi-1.6.4.tar.gz
cd spawn-fcgi-1.6.4
./configure
make;make install
//将编译出的可执行文件spawn-fcgi放至lighttpd的部署路径/usr/local/lighttpd/bin下
cp /usr/local/bin/spawn-fcgi /usr/local/lighttpd/bin
```
四、执行
在/usr/local/lighttpd/sbin目录下执行
```java
./lighttpd -f /usr/local/lighttpd/conf/lighttpd.conf
```
**附:**
一、创建组和用户
```java
groupadd lighttpd
useradd -g lighttpd -s /sbin/nologin -d /dev/null/ lighttpd
crown -R lighttpd:lighttpd /usr/local/lighttpd
```
二、配置文件修改
1、spawn-php.sh脚本修改
SPAWNFCGI="/usr/local/lighttpd/bin/spawn-fcgi
CGIPROGRAM="/usr/local/php-fcgi/bin/php"
USERID=lighttpd
GROUPID=lighttpd
2、lighttpd. conf修改
```java
var.log_root = "/usr/local/lighttpd"
var.server_root = "/usr/local/lighttpd"
var.state_dir = "/run"
var.home_dir = "/usr/local/lighttpd"
var.conf_dir = "/usr/local/lighttpd/conf"
然后注释掉IPv6
使能server.bind = "localhost"
server.username = "lighttpd"
server.groupname = "lighttpd"
server.document-root = sever_root + "/html"
//在配置文件最后添加以下代码
fastcgi.server = (".php"=>
("localhost"=>
(
"socket"=>"/tmp/php-fastcgi.socket",
"bin-path"=>"/usr/local/php-fcgi/bin/php-cgi"
)
)
)
```
3、modules. conf修改
放开mod_fastcgi注释
```java
server.modules = (
# "mod_rewrite",
"mod_access",
"mod_fastcgi",
# "mod_evasive",
# "mod_auth",
# "mod_authn_file",
# "mod_redirect",
# "mod_setenv",
# "mod_alias",
)
```
conf/conf.d/fastcgi.conf
直接将fastcgi的配置放在了lighttpd. conf里,这里的fastcgi. conf未做修改。
```java
./configure --enable-hmc --build=arm-linux --with-php-cinfig = /usr/local/php-fcgi/bin/php-config
```
网友评论