Lawliet has asked for the wisdom of the Perl Monks concerning the following question:
Update 2: Thanks to ikegami, it seems the problem was my installation PerlMagick (which is the module Image::Magick). Once I successfully reinstall it I will update once again.
Update: Added a sentence somewhere below for some possible clarification.
I haz (too much lolcatime) have a Perl program that creates a thumbnail from my pictures folder (~/Pictures/wallpapers). The program is located in /var/www/guest where there is a symlink to ~/Pictures/wallpapers and another a directory entitled thumbwalls. As most can guess, thumbwalls is where I try to write the thumbwalls. (I italicized 'try' to indicate failure, as most can guess.)
Let me further lucubrate:
I am using my desktop as my webserver. The following is located in my /etc/apache2/sites-available/default file.
<Directory /var/www/> AddHandler cgi-script .cgi .pl Options ExecCGI Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
As most can see, Symlinks are enabled ;).
Continuing on, the folder ~/Pictures/wallpapers has permissions set to "owner: create/delete files, group and others: access files" (not verbatim, as most can guess).
I am not sure what other information I can provide except the problematic code, so here goes.
Oh, wait, I should probably further expatiate the problem. Whenever I run the script it errors out saying it cannot find the specified file (which is /var/www/guest/wallpapers/:D.jpg -- a symlink to ~/Pictures/wallpapers/:D.jpg). I believe the problem may be Apache not wanting to go through the symlink. Note that I use absolute paths because Image::Magick demands I do so (I think). Also note that if I try to use the actual path to the file (not the symlink), it errors in the same way. Note that if I comment out the subroutines (err, comment out the one where I check for errors) it prints out all the pictures as their alt text, as well.
Without further adieu, for all intensive porpoises, code.
# Warnings, strictures, and modules be here. my $path = '/var/www/guest'; my $wallpath = $path.'/wallpapers'; my @walls = <$wallpath/*>; # Start html, table, and so on in place of this comment. # Need a better way to create a new Tr every 6th image for (my $i = 0; $i < $#walls; $i++) { my $currentpic = $walls[$i]; # Less confusion (my $filename = $currentpic) =~ s/.+\/(.+)/$1/; # Remove path my $thumbnail = "thumbwalls/t_$filename"; thumbnailize($currentpic, $thumbnail) unless -e $thumbnail; my $imgres = getInfo($currentpic); if ($i % 6 == 0) { print $query->start_Tr(); } # Print thumb and info about it if ($i % 6 != 0) { print $query->td( $query->a( {href => $currentpic}, img{src=>$ +thumbnail, alt=>$filename}), $query->br(), $imgres, ); next; } if ($i % 6 == 0) { print $query->end_Tr(); } } # End some things, do a little cleanup, the whole works here. sub thumbnailize { my ($pic, $thumb) = @_; my $image = Image::Magick->new; $image->Read($pic) or die $!; # I used die thinking it $image->Scale(geometry => '200x200'); # would catch error. $image->Write(filename => $thumb) or die $!; # It didn't. } sub getInfo { my $pic = shift; my $image = Image::Magick->new; print "workz" if -e $pic; # Prints successfully my $err = $image->Read($pic) or die $!; print $err if $err; # Errs successfully my ($xres, $yres) = $image->Get('x-resolution', 'y-resolution'); return "$xres x $yres"; }
I tried to keep the code relevant as well as show enough information. Feel free to ask for more information (the request may or may not be answered). Also, I have been frequently changing the code for a few days now so there may be some pleonasms. (The italicized 'have' was not used to indicate failure this time. Neither was that 'not'.)
Oh, let me recapitulate in case you have forgotten the problem. Either Apache (or Perl) does not see (or follow) the symlink to the picture.
And you didn't even know bears could type.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Apache2 and symlinks
by ikegami (Patriarch) on Jan 07, 2009 at 01:51 UTC | |
by Lawliet (Curate) on Jan 07, 2009 at 02:01 UTC | |
|
Re: (Updated -- Apache2 is irrelevant) Apache2 and symlinks
by shagbark (Acolyte) on Jul 12, 2012 at 04:48 UTC |