我配置好lighttpd,启动是可以的.配置ruby的环境如下.
$HTTP["host"] == "localhost" {
server.document-root = "/home/jy/rubygems/web/public"
server.error-handler-404 = "/dispatch.fcgi"
fastcgi.server = (".fcgi" =>
("localhost" =>
("min-procs" => 10,
"max-procs" => 10,
"socket" => "/home/jy/rails.socket",
"bin-path" => "/home/jy/rubygems/web/public/dispatch.fcgi",
"bin-environment" => ("RAILS_ENV" => "development")
)
)
)
我打开http://localhost出现如下错误.
Mysql::Error in MainController#index
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) RAILS_ROOT: /home/jy/rubygems/web
我打开本机的IP地址是可以的正常访问lighttpd的页面.
请高人帮我看看是什么问题.
[b]问题补充:[/b]
mysql肯定是启动的,因为加上:3000就可以正常的访问程序.
[b]问题补充:[/b]
socket = /var/lib/mysql/mysql.sock
[b]问题补充:[/b]
不是root权限,是一个普通用户.
[b]问题补充:[/b]
[root@localhost web]# script/server lighttpd -d
=> Booting lighttpd (use 'script/server webrick' to force WEBrick)
PROBLEM: Lighttpd is not available on your system (or not in your path)
[b]问题补充:[/b]
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/configs/
中的lighttpd.conf跟/etc/lighttpd/lighttpd.conf不一样.比这个少很少多内容.
[b]问题补充:[/b]
看来应该是以前配置文件的问题,但是不知道错误在哪里?
[b]问题补充:[/b]
[root@localhost web]# ./script/server lighttpd -d
=> Booting lighttpd (use 'script/server webrick' to force WEBrick)
=> Configuration in config/lighttpd.conf
=> Rails 2.2.2 application starting on http://0.0.0.0:3000
2009-03-17 16:04:02: (network.c.300) can't bind to port: 0.0.0.0 3000 Address already in use
[root@localhost web]#
看样子是可以了.
[b]问题补充:[/b]
那也得谢谢你了啊 :idea:
本人水平有限,看不出来……不如就先用这个吧XD
一点点改上去,然后你成为大牛以后就知道问题在哪了……
首先用ps -e| grep mysqld确保mysql已经启动
没启动就 /etc/init.d/mysqld start
如果还不行,大概development环境的原因?试试"RAILS_ENV" => "production"
AFAIK,还有一个可能是rails没有找到你的mysqld socket
先看看mysql的配置(一般是/etc/my.cnf或者/etc/mysql/my.cnf)
看看是不是socket = /var/lib/mysql/mysql.sock
如果不是,假设socket = /var/run/mysqld.sock,那么修改database.yml并加上
socket: /var/run/mysqld.sock
诡异……lighttpd是用超级用户权限启动的么……
从lib\ruby\gems\1.8\gems\rails-2.2.2\configs
复制一份lighttpd.conf
到/home/jy/rubygems/web/config目录下
sudo script/server lighttpd -d启动
如果ok,就是原先配置文件的问题,如果不行,就是mysql的问题……
[quote]PROBLEM: Lighttpd is not available on your system (or not in your path) [/quote]
lighttpd的可执行文件所在目录在PATH里了么?改改PATH再试试
那script/server lighttpd能跑吗?
官方给的配置示例是不错的学习文档,rails给的那个是精简版……