httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marat Khalili <>
Subject Re: [users@httpd] Permission to enable CGI Scripts to do an I/O on the file system
Date Fri, 11 Aug 2017 19:23:15 GMT
> So, there's no way of creating a log file in the default directory or some special directory

Apache usually logs stderr of CGI scripts to its error log, you can use this. If you give
any file or directory the permissions you observe on your /tmp file (something like writeable
by group www-data), it might work for debugging, or not if SELinux or apparmor gets in the

Better solution for debugging Python scripts is cgitb: it will show everything but syntax
errors in browser window, and syntax errors will still be visible in Apache logs. In production
you can configure cgitb to create tracefiles in a predefined directory.

(Also, typical initial problem with CGI scripts is forgetting to write HTTP headers.)

With Best Regards,
Marat Khalili

On August 11, 2017 9:20:19 PM GMT+03:00, Kiorp Pilu <> wrote:
>Hello Marat,
>Thanks for the comment.
>Yes, I am in the linux environment on a cluster. Tested your idea.
>1. The script works, but no output file is written on the cluster i.e.
>earlier I can't see anything in the console of my browser, now I see
>the script executes successfully read off from the console.
>[ <open file '/tmp/output.txt', mode 'a' at 0x7f1de42e4660> ]
>2. So, there's no way of creating a log file in the default directory
>some special directory ?
>However, I have set it up in Xampp and it works great, just worked out
>the box.
>On Fri, Aug 11, 2017 at 12:59 AM, Marat Khalili <> wrote:
>> You didn't specify system, so I assume it's a standard Linux
>> CGI scripts by default run with permissions of the web server, which
>> intentionally limited. However, you can create new files and
>directories in
>> /tmp, possibly using tempfile module. If you want more than just a
>> temporary file then you should consider using database since writing
>> arbitrary files from CGI scripts would otherwise cause concurrency
>> security problems.
>> --
>> With Best Regards,
>> Marat Khalili
>> On 11/08/17 00:29, Kiorp Pilu wrote:
>> Hello,
>> I have written a python script that will spit out a log file. This
>> script will be executed as a CGI script.
>> I am able to run the python program, but not able to make it write to
>> output file. How can I enable Apache web server to do so ?
>> Thanks,
>> Dann

View raw message