(一)lighttpd

1. 安装

yum install lighttpd

安装完毕后,系统中应该多了一个用户lighttpd和组lighttpd。这个用户,默认是不同意登陆的。

我们改动/etc/passwd,将lighttpd改动为例如以下形式。

lighttpd:x:489:470:lighttpd web server:/home/lighttpd/:/bin/bash

注意,你所示数字可能不是489,470,这个没关系,也不用改,保持原来的值就可以。

2. 为lighttpd用户创建一个文件夹,将站点的内容放进去

mkdir   /home/lighttpd

chown lighttpd:lighttpd   /home/lighttpd

创建相关子文件夹,并放入站点的内容。

注意,/home/lighttpd以lighttpd文件夹中的各种操作,都以lighttpd用户的身份来完毕。否则,lighttpd执行时可能会出现权限问题。

su lighttpd

cd /home/lighttpd

mkdir www

mkdir www/cgi-bin

mkdir www/databases

mkdir www/images

mkdir www/log

好了,如今能够往各个文件夹里放内容了,网页,图片,php脚本,sqlite数据库文件等。

index.html就放到www文件夹下。

3. 配置

改动lighttpd的配置文件  /etc/lighttpd/lighttpd.conf

a)打开cgi功能

当然,你也能够依据须要,打开其它的功能。我改动后的server.modules例如以下。

server.modules              = (

                                "mod_rewrite",

                                "mod_redirect",

#                               "mod_alias",

                                "mod_access",

#                               "mod_trigger_b4_dl",

#                               "mod_auth",

#                               "mod_status",

#                               "mod_setenv",

#                               "mod_fastcgi",

#                               "mod_proxy",

#                               "mod_simple_vhost",

#                               "mod_evhost",

#                               "mod_userdir",

                                "mod_cgi",

                                "mod_compress",

#                               "mod_ssi",

                                "mod_usertrack",

#                               "mod_expire",

#                               "mod_secdownload",

#                               "mod_rrdtool",

                                "mod_accesslog" )

b) 默认的文件名称

这里把default.xxx也给加上。

index-file.names            = ( "index.php", "index.html",

                                "index.htm", "default.htm", "default.php" )

c) 设置一些路径

server.document-root        = "/home/lighttpd/www/"



## where to send error-messages to

server.errorlog             = "/home/lighttpd/www/log/error.log"

accesslog.filename          = "/home/lighttpd/www/log/access.log"

#### php解析器的路径加上

cgi.assign                 = ( ".pl"  => "/usr/bin/perl",

                               ".php" => "/usr/bin/php-cgi" )

4. 启动lighttpd

service lighttpd start

5. 设置lighttpd开机自己主动启动

chkconfig --add lighttpd

(二)sqlite

这个简单,直接安装一下即可了。

yum install  sqlite

(三)php

1. 编译及安装

下载php源代码包

http://ar2.php.net/distributions/php-5.6.3.tar.bz2

将源代码包复制到 /root文件夹下

然后进入/root文件夹,运行例如以下命令序列

tar -xjf php-5.6.3.tar.bz2

cd php-5.6.3

./configure  --prefix=/usr --with-config-file-path=/etc --enable-libxml --with-libxml-dir=/usr/lib --with-sqlite3 --enable-pdo --with-pdo-sqlite CLAGS=-O2

make; make install

须要注意的是,这样的编译方式,支持訪问sqlite3的方式为pdo方式。这样的方式,不须要依赖不论什么extension

(四)測试

a)

用lighttpd用户,进入/home/lighttpd/www/databases文件夹,创建一个数据库

[lighttpd@localhost databases]$ sqlite3 test.db

SQLite version 3.6.22

Enter ".help" for instructions

Enter SQL statements terminated with a ";"

sqlite> create table my_friends(name varchar(10), age smallint);

sqlite> insert into my_friends values('tom',22);

sqlite> insert into my_friends values('liyan',21);

输入ctrl+d退出sqlite shell

b) 用lighttpd用户,进入cig-bin文件夹,创建一个php脚本haha.php,内容例如以下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

</head>



<body>



<?php

    //phpinfo();

    echo "hello  我的第一个php脚本<br>";

    echo getcwd();

        

    $file_db = new PDO('sqlite:../databases/test.db');

    $result = $file_db->query('SELECT * FROM my_friends');

        

    foreach($result as $row) 

    {

        echo " name: ".$row['name']."<br>";

    }

?>



</body>

</html>

c) 用浏览器訪问haha.php看看效果吧 :)

http://ip_of_lighttpd/cgi-bin/haha.php

假设在调试php程序时,遇到问题,能够打开/etc/php.ini,设置例如以下内容,以打开php的报错功能:

error_reporting = E_ALL & ~E_NOTICE

display_errors = On

fedora linux平台下搭建lighttpd+php+sqlite的更多相关文章

  1. Perl Tk在IC设计中的应用、Windows、Linux平台下的安装-各种错误的摸索解决

    本文转自:自己的微信公众号<集成电路设计及EDA教程> <Perl Tk在IC设计中的应用.Windows.Linux平台下的安装-各种错误的摸索解决> Perl在IC设计中有 ...

  2. 在Linux(Ubuntu)下搭建ASP.NET Core环境并运行 继续跨平台

    最新教程:http://www.cnblogs.com/linezero/p/aspnetcoreubuntu.html 无需安装mono,在Linux(Ubuntu)下搭建ASP.NET Core环 ...

  3. linux平台下防火墙iptables原理(转)

    原文地址:http://www.cnblogs.com/ggjucheng/archive/2012/08/19/2646466.html iptables简介 netfilter/iptables( ...

  4. Windows及Linux平台下的计时函数总结

    本文对Windows及Linux平台下常用的计时函数进行总结,包括精度为秒.毫秒.微秒三种精度的各种函数.比如Window平台下特有的Windows API函数GetTickCount().timeG ...

  5. Thrift在Windows及Linux平台下的安装和使用示例

    本文章也同时发表在个人博客Thrift在Windows及Linux平台下的安装和使用示例上. thrift介绍 Apache Thrift 是 Facebook 实现的一种高效的.支持多种编程语言的R ...

  6. Linux平台下裸设备的绑定:

    Linux平台下裸设备的绑定: 运用RAW绑定 方法一 raw的配置(1) [root@qs-dmm-rh2 mapper]# cat /etc/rc.local #!/bin/sh # # This ...

  7. 在Linux 环境下搭建 JDK 和 Tomcat

      在Linux 环境下搭建 JDK 和 Tomcat 参考地址:http://www.cnblogs.com/liulinghua90/p/4661424.html   [JDK安装] 1.首先下载 ...

  8. Linux平台下源码安装mysql多实例数据库

    Linux平台下源码安装mysql多实例数据库[root@linux-node1 ~]# netstat -tlunp | grep 330tcp6 0 0 :::3306 :::* LISTEN 6 ...

  9. Windows 和 Linux 平台下的端口转发工具

    原文地址: http://unmi.cc/windows-linux-port-forwarding/ 这里记录一下我曾经使用过的几个端口转发工具,即端口映射.端口重定向,和 NAT 也是差不多的概念 ...

随机推荐

  1. curl订单具体解释

    为windows假设用户Cygwin模拟unix环境的话,不会有带curl命令,拥有设备,它建议使用Gow为了模拟,它已经自带curl工具,直接安装之后cmd使用环境curl命令可以,由于路径是自己主 ...

  2. [Cocos2d-x]CCSpriteBatchNode的使用

    文档: http://cocos2d.cocoachina.com/document/index/class?url=dd/d95/classcocos2d_1_1_c_c_sprite_batch_ ...

  3. POJ--3268--Silver Cow Party【SPFA+邻接表】

    题意:一些牛要去某一点參加聚会,然后再回到自己家,路是单向的,问花费时间最多的那头牛最少须要花费多长时间. 思路:从聚会地点返回,相当于是从某一点到其它各个点的最短路径.从牛的家中走到聚会地点,能够把 ...

  4. 关于jdbc注冊驱动的那点事

    看到非常多人写jdbc连接工具类的时候,都会写到Class.forName()去显示载入类,一写错点点就会抛出ClassNotFoundException,关于显示载入类,究竟会不会产生作用呢? 參考 ...

  5. Android NDK入门实例 计算斐波那契数列一生成jni头文件

    最近要用到Android NDK,调用本地代码.就学了下Android NDK,顺便与大家分享.下面以一个具体的实例计算斐波那契数列,说明如何利用Android NDK,调用本地代码.以及比较本地代码 ...

  6. atitit.高级编程语言的特性 and 未来趋势与进化.doc

    atitit.高级编程语言的特性 and 未来趋势与进化.doc 1 编程语言的发展历程 1 1.1 编程语言的进化,起始发现背后的思想 :不论什么两个系统之间的复杂性,都能够通过加入一个抽象层要屏蔽 ...

  7. js中点击空白区域时文本框与隐藏层的问题

    当文本框获得焦点的时候,在文本框的下方显示一个浮动层. 当用户点击除了文本框和浮动层以外的网页空白处时,要隐藏浮动层. 当用户点击浮动层时,改变文本框的值. <!DOCTYPE html PUB ...

  8. Java中对不变的 data和object reference 使用 final

    Java中对不变的 data和object reference 使用 final 许多语言都提供常量数据的概念,用来表示那些既不会改变也不能改变的数据,java关键词final用来表示常量数据.例如: ...

  9. OSPF理论总结

    OSPF学习总结一.OSPF协议的报文类型: 1. Hello 报文:主要用来发现.建立和维护邻居关系. 2. DD报文:数据库的描述报文,主要用来两台路由器的数据库同步. 3. LSR报文:链路状态 ...

  10. cocostudio内存释放

    在使用cocostudio时,在释放内存时能够这样做: 在onExit()方法里加入例如以下: void LoadLayer::onExit() { // 释放本对象自己 removeFromPare ...