I am trying to upload files to a web server running Apache/2.4.6 on CentOS 7 using a simple Perl script. I get a permission denied message. My code:
[user@machine cgi-bin]$ cat test.pl
#!/usr/bin/perl
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
print header;
print start_html(-title => "Test");
print "<center> <h1> Hello </center>\n";
my $filename = "/home/apache/test.txt";
open(my $FILE, ">$filename");
if(-e $filename) {
print "$filename exists\n";
print $FILE "Hello\n";}
else {
print "$filename does not exist\n";}
close($FILE);
print end_html;
After reviewing previous answers I changed permission to the /home/apache directory and changed owner to apache.
drwxrwxrwx. 2 apache root 37 May 30 18:54 apache
Still, when I run the test.pl script manually the file is created, and when I open it in web browser the file does not. Help will be much appreciated. Thank you.