Zend_Search_Lucene - 无法创建目录“/data/users_index”
我在使用 Zend_Search_Lucene 创建索引时遇到问题。
现在,我的本地计算机上一切正常,所以我猜只是网络服务器上的文件权限存在问题。
以下是我尝试在控制器中创建索引的方法:
$index = Zend_Search_Lucene::create('/data/users_index');
当然,数据目录的权限设置为 0777。这是目录列表:
public_html
public 0755
css 0755
js 0755
data 0777
但我收到此错误:
无法创建目录“/data/users_index”。
I have a problem creating an index with Zend_Search_Lucene.
Now, everything works fine on my local machine so I guess there is just an issue with file permissions on the webserver.
Here is how I'm trying to create index in controller:
$index = Zend_Search_Lucene::create('/data/users_index');
Of course the data directory has permissions set to 0777. Here is the directory listing:
public_html
public 0755
css 0755
js 0755
data 0777
Yet I'm getting this error:
Can't create directory '/data/users_index'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
$index = Zend_Search_Lucene::create('public/data/users_index');
??
$index = Zend_Search_Lucene::create('public/data/users_index');
??
编辑/更新
:在进一步阅读并查看您的结构后,我会尝试一下并尝试使用ABSOLUTE
路径而不是相对路径以确保其写入写入位置。 抱歉我之前错过了那部分。 这显然不是最佳实践,但它至少会缩小是否是许可/发现问题的范围。因此,将其更改为类似
尽管,您确实应该将其放在公共 HTML 文件夹之外。 公众没有理由有权访问您的 Lucene 索引文件。
例如,我的存储在这里:
如果您使用的是 Linux/Unix 计算机,则必须 CHMOD 文件夹或 CHOWN/CHGRP 以便 Web 服务器具有写入权限。 如果您有权访问服务器,您可以简单地运行:
但是,如果您不是服务器的管理员,您可能应该要求服务器管理员确保这是应用于此文件夹的正确权限,每个管理员都有他的权限/她自己对于如何设置文件夹权限的怪癖; 他们应该属于哪个组; 谁可以改变它; 如果您使用的是 Windows 计算机,则
必须右键单击该文件夹并向
IUSR_XXXXX
帐户授予权限,并授予他们对该文件夹的读/写访问权限。 (将 XXX 替换为您的机器名称)Edit/Update
: After further reading and seeing your structure, I'd give it a shot and try using anABSOLUTE
path rather than a relative to ensure its writing to the write location. Sorry I missed that portion earlier. It's obviously not the best practice, but it would atleast narrow down whether or not its a permission/finding issue.So change it to something like
Although, you really should put that outside of the public HTML folder. There's no reason that the public should have access to your Lucene Index Files.
For example, mine are stored here:
If you are on a Linux/Unix machine, you are going to have to CHMOD the folder or CHOWN/CHGRP so that the web server has write access. If you have access to the server, you could simply run:
If you are not the admin of the server however, you should probably ask the server admin to make sure this is the proper permissions to be applied to this folder, every admin has his/her own quirks about how they want folder permissions setup; what group they should be in; who gets to change it; etc.
If you are on a Windows machine, you are going to have to right click on the folder and grant permissions to the
IUSR_XXXXX
account and give them read/write access to that folder. (Replace XXX with whatever your machines name is)