niemanlab / openfuego

Watching Twitter all day—so you don’t have to.
http://www.niemanlab.org/fuego
MIT License
175 stars 53 forks source link

Error running fetch.php #4

Closed mAAdhaTTah closed 10 years ago

mAAdhaTTah commented 10 years ago

When I run fetch.php from the CLI, I get this

PHP Fatal error: Class 'OpenFuego\app\Universe' not found in /var/www/OpenFuego/collect.php on line 34

I'm pretty much a total beginner w PHP, so apologies in advance if there's something basic I'm missing.

phelps commented 10 years ago

Hmm, what environment are you running? (PHP version, operating system, MySQL version…)

mAAdhaTTah commented 10 years ago

PHP 5.3.10-1ubuntu3.7 with Suhosin-Patch Ubuntu 12.04 LTS MySQL: Server version: 5.5.32-0ubuntu0.12.04.1 (Ubuntu)

phelps commented 10 years ago

Looks good, and I assume all the files and original paths are intact, yes?

I'm kind of baffled.

mAAdhaTTah commented 10 years ago

They are - everything resides in the folder /var/www/OpenFuego. If nothing jumps out at you, I'll play around with the permissions, see if that's the problem.

mAAdhaTTah commented 10 years ago

I gave it the widest permissions possible, now I'm getting a new error:

PHP Fatal error: Call to undefined function curl_init() in /var/www/OpenFuego/lib/TwitterOAuth/TwitterOAuth.class.php on line 195

But it appears curl_init is a standard php function

http://php.net/manual/en/function.curl-init.php

So something must be wrong with my set up. Time to play sysadmin...

Edit: apparently, curl needs to be installed.

http://askubuntu.com/questions/9293/how-do-i-install-curl-in-php5

Now I run fetch.php and I get no errors!

mAAdhaTTah commented 10 years ago

Well, not quite:

PHP Warning: unlink(/var/www/OpenFuego/tmp/CollectorQueue.20130729-072800.queue): No such file or directory in /var/www/OpenFuego/app/Consumer.class.php on line 132 PHP Warning: fopen(/var/www/OpenFuego/tmp/CollectorQueue.20130729-072811.queue): failed to open stream: No such file or directory in /var/www/OpenFuego/app/Consumer.class.php on line 81

simondahla commented 10 years ago

I got the same problem as you @mAAdhaTTah

mAAdhaTTah commented 10 years ago

Figured out the problem: I changed the ownership of the OpenFuego folder to www-data:www-data (I believe this is the apache user). That got everything working for me. @simondahla - try that, let me know if that works. Also, which error did you get? The first (PHP Fatal Error) or the second (PHP Warning)?

Edit: it appears to be working so far (the example getItems.php now pulls links) but I'm getting this error:

PHP Warning: unlink(/var/www/OpenFuego/tmp/CollectorQueue.20130729-091830.queue): No such file or directory in /var/www/OpenFuego/app/Consumer.class.php on line 132

I think this might be a holdover from previous trynfails. I'm going to try and reset the whole thing and start from scratch with the proper permissions and see if I can clear out all these problems once and for all.

phelps commented 10 years ago

One thing to be sure of, that I should make clear in the documentation: Always quit all Fuego processes before trying to start it up again. That unlink error suggests to me you had one process running but not the other.

Before running fetch, do a killall php (assuming there are no other important PHP processes running). Andrew.

On Mon, Jul 29, 2013 at 9:18 AM, mAAdhaTTah notifications@github.com wrote:

Figured out the problem: I changed the ownership of the OpenFuego folder to www-data:www-data (I believe this is the apache user). That got everything working for me. @simondahla - try that, let me know if that works. Also, which error did you get? The first (PHP Fatal Error) or the second (PHP Warning)?

Reply to this email directly or view it on GitHub: https://github.com/niemanlab/openfuego/issues/4#issuecomment-21718930

mAAdhaTTah commented 10 years ago

I have other things running on that server (a WordPress blog, plus some other things). I'll look at how to kill specific pids, I think? In any case, thanks for the headsup.

phelps commented 10 years ago

Those other programs are not running in background processes, most likely. PHP processes are normally a blip that last as long as the script needs to execute some function. OpenFuego is unusual in that it never terminates.

mAAdhaTTah commented 10 years ago

Ok, good to know, thanks.

So here's where I'm at: I upload the files, chown them to www-data, and run fetch.php and it "runs" insofar as there are no errors reported immediately.

It creates the tmp folder, which I also them chown to www-data (I know there's a way to make it do that automatically, but I'll have to go back and figure that out). Then, I get this error:

PHP Warning: unlink(/var/www/OpenFuego/tmp/CollectorQueue.20130729-124145.queue): Permission denied in /var/www/OpenFuego/app/Consumer.class.php on line 132

However, after I chown them, I do get links starting to get posted in getItems.php. Being a php-noob, I don't see what's on line 132 that's causing a fuss though. @phelps - thoughts?

phelps commented 10 years ago

The Consumer is reading log files and deleting them constantly. Fuego needs permissions to create and delete these files itself. If you are setting permissions manually, it won't work.

mAAdhaTTah commented 10 years ago

Thanks so much for your help, @phelps! I'll play around with this some more, and I'll put together some documentation on how to set this up on Ubuntu.

I'll eventually deploy this on AWS as well, so I'll put together some docs for that when I get around to it.

phelps commented 10 years ago

Cool, no problem. Please close this issue when you feel like it's resolved.

mAAdhaTTah commented 10 years ago

Ugh, I'm not a Linux expert either, so this is becoming more difficult that I first expected. As far as I can tell, it's a permissions issue - the problem is you execute the fetch.php as your main user (in my case, maadhattah), but the files created are created by the webserver user www-data. But if it gets chowned by www-data, it's unable to create and delete the files? I dunno what's going on, to be honest.

In any case, I think this is beyond your concern - if you have any last thoughts, let me know, but otherwise, I'll go ahead and close this tomorrow morning. I'm going to need to set this aside and come back to it.

phelps commented 10 years ago

For me, figuring out permissions and running Apache was the single hardest part of learning how to administer a server. This is how I do it (I am running a similar Ubuntu environment):

My user name (phelps) is a member of the www-data group. To do that:

usermod -a -G www-data phelps

My www directory and everything inside it is owned by phelps:www-data. I did that this way:

chown -R phelps:www-data /path/to/www/

The user who owns it doesn't matter, just the group. All new files created are be owned by the www-data group by default. How? By running this once:

chmod g+s /path/to/www/

Make sure /etc/apache2/envvars points to the www-data group, too.

Assuming you CHMOD files to allow world reading and group writing, you should be set. Because OpenFuego files are in the www-data group, it should be able to write files to a directory, and if OpenFuego is the owner of the files, it can do whatever it likes with them.

mAAdhaTTah commented 10 years ago

... by golly, I think it's working ...

I'll let it run a bit, double check the getItems.php in an hour or so, but I think that did it. Thanks SO MUCH for your help.

mAAdhaTTah commented 10 years ago

Last question, I swear: how long does it have to run before getItems.php will return data? I'm running it in verbose mode, so I see it's working, but opening getItems.php gives me a blank page.

phelps commented 10 years ago

Set $scoring to false if you want data immediately. Otherwise it can be hours before the freshness vs. quality algorithm surface links deemed high-quality.

No bother at all, by the way. Andrew.

On Mon, Jul 29, 2013 at 7:00 PM, mAAdhaTTah notifications@github.com wrote:

Last question, I swear: how long does it have to run before getItems.php will return data? I'm running it in verbose mode, so I see it's working, but opening getItems.php gives me a blank page.

Reply to this email directly or view it on GitHub: https://github.com/niemanlab/openfuego/issues/4#issuecomment-21758201

mAAdhaTTah commented 10 years ago

So that's a feature not a bug.

Yup, that works - we are good. to. go.

Closed!