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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.