Apache web server cannot write to a server file on Solaris10

I am running Apache version 2.2.26 on a  Solaris 10 server:
# uname -a
SunOS v12345 5.10 Generic_139555-08 sun4u sparc SUNW,Sun-Fire-V240

It is running the the httpd as the user name "myuserwww"
#ps -ef | grep httpd
myuserwww 14221  4855   0   Mar 30 ?           0:06 /usr/local/apache2/bin/httpd -k restart

I am running an application on the apache web server. The application write to a text file under:
/usr2/mydir/mydir2/myfile.txt

The entire directory and files under /usr2/mydir/mydir2 are owned by myuserwww.

Everything was working. Suddenly I see that the web application can no longer write to the file /usr2/mydir/mydir2/myfile.txt . The submit button stays spinng forever -- the submit tries to write to the TEXT file.

The webserver error log does not show any information.
How to troubleshoot?
toookiAsked:
Who is Participating?
 
TintinCommented:
As I suspected, you have no error checking.

open FILE, ">>$DIR/vendor_info.txt" or die "Can not append to vendor_info.txt because $!\n";

Open in new window


Add

use CGI::Carp 'fatalsToBrowser';

Open in new window


if you don't have it already.

0
 
arnoldCommented:
Check permissions. su - myuserwww and see whether you can get to the location to perform the same task. Check /var/adm/messages to see whether a security violation is logged.
0
 
TintinCommented:
1.  What are the permissions on /usr2/mydir/mydir2/myfile.txt

2.  What type of error checking/reporting does the app do?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
toookiAuthor Commented:
Thank you for your help.

The file is owned by myuserwww. I set its ownership as read/write for all (chmod 777 filename).
I can su - myuserwww and then can write to that file and create new file.
$ id
uid=32006(myuserwww) gid=5000(www)
$ hostname > junk.txt
$ cat junk.txt
myhostname

I wrote the application and in apache config file -- I mentioned the error and access log file locations. But those files don't give any relevant information.

Under /var/adm/ I see a file messages-ng which is being written with info. But no relevant error in it.

0
 
TintinCommented:
What's the application written in?

The point I was trying to deterrmine is if you have error checking in the application itself.

I see a lot of code where a file is opened for writing and no check is done to see if it opened successfully or not.
0
 
toookiAuthor Commented:
Thank you.
The application is written in Perl. I has been an application code running without problem for long.

The Perl code creates a web front end.. The submit button when press does some work that includes:

if (-e "$DIR/vendor_info.txt")
{
open (FILE, "<$DIR/vendor_info.txt") || print "<P>Unable to open vendor_info.txt\n" ;
@lines = <FILE>;
close FILE;
}

#The above part works fine. The Perl code reads the file content parses it and displays it on the webpage.

Later in the code:

open (FILE2, ">>$DIR/vendor_info.txt");
print FILE2 "$vn ; $vc ; $ve ; $vf\n";
close FILE2;


It seems when writing to the file, the webpage gets stuck.
0
 
toookiAuthor Commented:
Thank you.
I have added use CGI::Carp 'fatalsToBrowser';
Also added the or die "Can not append to vendor_info.txt because $!\n"; part.
But still it hangs. It seems to me something else (not the file permission or so) is causing the matter. Looking into it.
0
 
TintinCommented:
You should add some debug statements so you know what stage it's getting up to, eg:

print "Opening file<br>\n";
open .....

Open in new window


0
 
toookiAuthor Commented:
Thank you. I followed the error checking steps.
Finally I found that the issue was with connecting to a different server via the code. It was taking long for the code to connect to that server and was getting stuck. I removed that piece of code and everything got fixed.

I am anyway going to use the error checking steps that you mentioned.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.