首页 > 服务器 > openwrt上用lighttpd+php+mysql建站.

作者:ghostry 发布时间:2012-11-30 浏览: 12172

转载注明出处: https://blog.ghostry.cn/server/openwrt-shang-yong-lighttpd-php-mysql-jian-zhan.html

这里简单记录了在openwrt上面安装网站的方法.
一,软件安装

opkg install lighttpd-mod-fastcgi php5-fastcgi php5-mod-mysql php5-mod-pdo-mysql php5-mod-session mysql-server

如果是要用typecho建博客,最好再装几个

opkg install lighttpd-mod-rewrite php5-mod-tokenizer php5-mod-ctype


二,配置
/etc/lighttpd/lighttpd.conf
修改或添加的部分.
加载模块

	server.modules = ( 
 "mod_rewrite", 
 "mod_fastcgi",
)

根目录

	server.document-root="/www/"

主页文件

	index-file.names = ( "index.html", "default.html", "index.htm", "default.htm","index.php"  )

调用php

fastcgi.server = ( 
 ".php" =>
 (( "socket" => "/tmp/php-fastcgi.socket",
 "bin-path" => "/usr/bin/php-fcgi",
 "min-procs" => 0,
 "max-procs" => 1,#这个是php-cgi最大进程数,如果设备配置好,数字最好能大点.
 "idle-timeout" => 10,
 "bin-environment" => (
 "PHP_FCGI_CHILDREN" => "0",#php-cgi子进程数,设备好的最好大一点.最后总进程数计算方法为max-procs*(PHP_FCGI_CHILDREN+1)
 "PHP_FCGI_MAX_REQUESTS" => "1000"
 ),
 "bin-copy-environment" => ( "PATH", "SHELL", "USER" ),
 "broken-scriptfilename" => "enable"
 ))
 )

typecho的伪静态文件,我的是在/blog子目录下.根据自己的实际情况修改下.

 url.rewrite = (
 "^/blog/(.*)\.html$" => "/blog/index.php/$1\.html",
 "^/blog/archives/(.*)" => "/blog/index.php/archives/$1",
 "^/blog/category/(.*)" => "/blog/index.php/category/$1",
 "^/blog/([0-9]+)/([0-9]+)/$" => "/blog/index.php/$1/$2/",
 "^/blog/tag/(.*)/$" => "/blog/index.php/tag/$1",
 "^/blog/search/(.*)/$" => "/blog/index.php/search/$1",
 "^/blog/(.*)page/(.*)" => "/blog/index.php/$1page/$2",
 "^/blog/(feed.*)" => "/blog/index.php/$1",
 "^/blog/action/(.*)" => "/blog/index.php/action/$1",
 "^/blog/(.*)/comment" => "/blog/index.php/$1/comment"
 ) 


/etc/php.ini


加载mod

extension=ctype.so
extension=mysql.so
extension=pdo.so
extension=pdo-mysql.so
extension=session.so
extension=tokenizer.so

和mysql的连接

pdo_mysql.default_socket= /var/run/mysqld.sock
mysql.default_socket = /var/run/mysqld.sock


时区

date.timezone = Asia/Chongqing


网站根目录设置注释掉,不需要在这写.

;doc_root = "/www"


/etc/my.cnf
接口

socket = /var/run/mysqld.sock

所有地址监听

bind-address = 0.0.0.0

数据库目录

datadir = /mnt/sda2/data/
tmpdir = /mnt/sda2/data/tmp/


初始化数据库

/usr/bin/mysql_install_db --force


三,启动

/etc/init.d/lighttpd start
/etc/init.d/mysqld start

设置密码

mysqladmin -u root password 00000000


这样就启动了.
顺利的话,就可以访问网站了.

标签: php openwrt lighttpd mysql 网站建设

上一篇: o(∩_∩)o 哈哈
下一篇: css3设置圆角div

添加新评论 »

*
*

欢迎评论!歡迎評論!Comments welcome!komentoj bonvenaj!댓글 오신 것을 환영합니다!
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: :cold: :cryy: :cute: :shy: :sleep: :struggle: :tea: :yahou: