views:

186

answers:

2

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'.

A: 

Hi

$index = Zend_Search_Lucene::create('public/data/users_index');

??

ArneRie
That doesn't work either I already tried that (it works on my local machine, too, of course but not on the server online).
Richard Knop
+3  A: 

Edit/Update: After further reading and seeing your structure, I'd give it a shot and try using an ABSOLUTE 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

$index = Zend_Search_Lucene::create('/path/to/public_html/public/data/users_index');

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:

'../application/models/lucene/articles/index'


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:

chmod -R 770 /path/to/your/data/users_index

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)

Jesta
In most ZF applications you have an APPLICATION_PATH defined - use it - APPLICATION_PATH.'/models/lucene/articles/index'
gnarf
Actually I changed it to $index = Zend_Search_Lucene::create('data/users_index'); and it works. Weird. On my local machine it doesn't matter if I put slash in the beginning or not...
Richard Knop