My CGI script cannot be written to the cgi-bin folder of Apache

I am developing a python version of the cgi script, it needs to create an img file in the cgi-bin folder (will be displayed on the web page).

But it failed:
[Wed Oct 28 16:13:51 2009] [Error] [client :: 1] OSError: [Errno 13] Permission denied:’average /’

[Note]’average /’is the first folder created by the cgi script to save these img files.

I tried to give the cgi script an x ​​permission, but it still failed. This is in Win and It happens on Mac.

By the way, I am using the default Apache configuration. I did not change anything after installing Apache.

You must grant the web server user write access to the cgi-bin folder. Generally, the web server user is similar to nobody and is not in the same group as the owner of the folder , So this means making cgi-bin writable: Note: This is a very bad idea.

chmod a+rwx cgi-bin< /pre> 

(Alternatively, set cgi-bin permissions on Windows to provide "full control" for everyone.)

Now, any user on the server or anyone who has not checked it properly The script of the file name may create a file in cgi-bin, and Apache interprets it as a CGI script and executes it. This is a good way for your server to have it.

The file written at runtime should Put it in a separate "data" folder outside of cgi-bin (preferably outside the web root directory, bind with Alias), Apache is set to prohibit deleting any type of script or htaccess from this folder. Then, You can set "data" to 777, or better yet, let it be owned by the web server user.

I am developing a python version of the cgi script, and it needs to be in Create an img file in the cgi-bin folder (will be displayed on the web page).

But it failed:
[Wed Oct 28 16:13:51 2009] [Error] [ client :: 1] OSError: [Errno 13] Permission denied :'Average /'

[Note]'average /'is the first folder created by the cgi script to save these img files.

I try to give the cgi script an x Permissions, but it still fails. This happens on both Win and Mac.

By the way, I am using the default Apache configuration. I did not change anything after installing Apache.

< /p>

You must grant the web server user write access to the cgi-bin folder. Generally, the web server user is similar to nobody and is not in the same group as the owner of the folder , So this means making cgi-bin writable: Note: This is a very bad idea.

chmod a+rwx cgi-bin< /pre> 

(Alternatively, set cgi-bin permissions on Windows to provide "full control" for everyone.)

Now, any user on the server or anyone who has not checked it properly The script of the file name may create a file in cgi-bin, and Apache interprets it as a CGI script and executes it. This is a good way for your server to have it.

The file written at runtime should Put it in a separate "data" folder outside of cgi-bin (preferably outside the web root directory, bind with Alias), Apache is set to prohibit deleting any type of script or htaccess from this folder. Then, You can set "data" to 777, or better yet, let it be owned by the web server user.

Leave a Comment

Your email address will not be published.