日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

lighttpd sqlite3 php,fedora linux平台下搭建lighttpd+php+sqlite

發布時間:2024/9/27 linux 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 lighttpd sqlite3 php,fedora linux平台下搭建lighttpd+php+sqlite 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

(一)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" )

4. 啟動lighttpd

service lighttpd start

5. 設置lighttpd開機自動啟動

chkconfig --add lighttpd

(二)sqlite

這個簡單,直接安裝一下就行了。

(三)php

下載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

需要注意的是,這種編譯方式,支持訪問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,內容如下:

//phpinfo();

echo "hello ?我的第一個php腳本\n";

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']." ";

}

?>

c) 用瀏覽器訪問haha.php看看效果吧 :)

總結

以上是生活随笔為你收集整理的lighttpd sqlite3 php,fedora linux平台下搭建lighttpd+php+sqlite的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。