CGI configuration on Apache

Mac OS X 平台上程式設計的相關問題討論

版主: bryanchangdigdog謝孟叡

回覆文章
內容
發表人
頭像
luisehsu
留言破百
文章: 147
註冊時間: 07/04/2001 1:01 am
來自: Nowhere to Nowhere
聯繫:

CGI configuration on Apache

#1 文章 luisehsu »

sorry for this basic question:
1. the DocumentRoot is /var/www/html
2. below is my configuration relative cgi configuration in httpd.conf:

代碼: 選擇全部

ScriptAlias /cgi-bin/ /var/www/cgi-bin/                                                                       
AddHandler cgi-script cgi pl                                                                                  
                                                                                                              
<Directory /home/*/htdoc>                                                                                     
    AllowOverride FileInfo AuthConfig                                                                         
    Options MultiViews -Indexes SymLinksIfOwnerMatch IncludesNoExec +ExecCGI                                  
    Order allow,deny                                                                                          
    Allow from all                                                                                            
</Directory>
3. when i try to run a test script (perl), which is located in /var/www/cgi-bin/ and /home/user_name/htdoc/, through web, i got 403(forbidden) and 500(internal error) message
4. however, if i relocate test-script in /var/www/perl, the script runs fine
5. system information:
Apache 1.3.26 on Mandrake Linux 9.0

besides, i found there are two conf file, httpd.conf and httpd-perl.conf which are almost identical, except the additional configuration i add in httpd.conf

thanks
Fortune favors the bold.
- Virgil (70 BC - 19 BC)
fddi1
留言破百
文章: 188
註冊時間: 05/03/2001 1:01 am
來自: USA/Seattle, WA
聯繫:

Re: CGI configuration on Apache

#2 文章 fddi1 »

Make sure your cgi script has the correct permission.
Podcast節目
AIRLOG podcast
SNAPPLE LAB 實驗試管
AIRLOG podcast在iTMS上的列表
頭像
luisehsu
留言破百
文章: 147
註冊時間: 07/04/2001 1:01 am
來自: Nowhere to Nowhere
聯繫:

Re: CGI configuration on Apache

#3 文章 luisehsu »

fddi1 寫:Make sure your cgi script has the correct permission.
the owner of script is rootand permission is 755
i suppose this should be sufficient enough for cgi execution

thanks
Fortune favors the bold.
- Virgil (70 BC - 19 BC)
fddi1
留言破百
文章: 188
註冊時間: 05/03/2001 1:01 am
來自: USA/Seattle, WA
聯繫:

Re: CGI configuration on Apache

#4 文章 fddi1 »

luisehsu 寫:
fddi1 寫:Make sure your cgi script has the correct permission.
the owner of script is rootand permission is 755
i suppose this should be sufficient enough for cgi execution

thanks
Give it a 777 for a test and see if it works. :wink:
Podcast節目
AIRLOG podcast
SNAPPLE LAB 實驗試管
AIRLOG podcast在iTMS上的列表
fddi1
留言破百
文章: 188
註冊時間: 05/03/2001 1:01 am
來自: USA/Seattle, WA
聯繫:

Re: CGI configuration on Apache

#5 文章 fddi1 »

fddi1 寫:
luisehsu 寫:
fddi1 寫:Make sure your cgi script has the correct permission.
the owner of script is rootand permission is 755
i suppose this should be sufficient enough for cgi execution

thanks
Give it a 777 for a test and see if it works. :wink:
BTW, make sure your cgi-bin directory has the right permission as well.
Podcast節目
AIRLOG podcast
SNAPPLE LAB 實驗試管
AIRLOG podcast在iTMS上的列表
頭像
luisehsu
留言破百
文章: 147
註冊時間: 07/04/2001 1:01 am
來自: Nowhere to Nowhere
聯繫:

Re: CGI configuration on Apache

#6 文章 luisehsu »

fddi1 寫:
fddi1 寫: Give it a 777 for a test and see if it works. :wink:
BTW, make sure your cgi-bin directory has the right permission as well.
well
my cig-bin directory and test-script are totally opened now (set to 777)
and i still get the 403 forbidden error message

thanks
Fortune favors the bold.
- Virgil (70 BC - 19 BC)
fddi1
留言破百
文章: 188
註冊時間: 05/03/2001 1:01 am
來自: USA/Seattle, WA
聯繫:

Re: CGI configuration on Apache

#7 文章 fddi1 »

luisehsu 寫:
fddi1 寫:
fddi1 寫: Give it a 777 for a test and see if it works. :wink:
BTW, make sure your cgi-bin directory has the right permission as well.
well
my cig-bin directory and test-script are totally opened now (set to 777)
and i still get the 403 forbidden error message

thanks
In that case, check both your access_log and error_log on your Apache server, and see what they say.
Podcast節目
AIRLOG podcast
SNAPPLE LAB 實驗試管
AIRLOG podcast在iTMS上的列表
頭像
luisehsu
留言破百
文章: 147
註冊時間: 07/04/2001 1:01 am
來自: Nowhere to Nowhere
聯繫:

Re: CGI configuration on Apache

#8 文章 luisehsu »

fddi1 寫: In that case, check both your access_log and error_log on your Apache server, and see what they say.
these are what i got from error_log:

代碼: 選擇全部

[Mon Mar 31 17:30:41 2003] [error] Premature end of script headers: /home/user_name/htdoc/test.cgi                                                                                                     
[Mon Mar 31 17:31:19 2003] [error] client denied by server configuration: /var/www/cgi-bin/test.cgi
the former one is generated while accessing cgi in home directory, and later one by accessing cgi in /cgi-bin directory
the configuration of httpd.conf is still the same, and permission has changed to 777

thanks
Fortune favors the bold.
- Virgil (70 BC - 19 BC)
fddi1
留言破百
文章: 188
註冊時間: 05/03/2001 1:01 am
來自: USA/Seattle, WA
聯繫:

Re: CGI configuration on Apache

#9 文章 fddi1 »

luisehsu 寫:
fddi1 寫: In that case, check both your access_log and error_log on your Apache server, and see what they say.
these are what i got from error_log:

代碼: 選擇全部

[Mon Mar 31 17:30:41 2003] [error] Premature end of script headers: /home/user_name/htdoc/test.cgi                                                                                                     
[Mon Mar 31 17:31:19 2003] [error] client denied by server configuration: /var/www/cgi-bin/test.cgi
the former one is generated while accessing cgi in home directory, and later one by accessing cgi in /cgi-bin directory
the configuration of httpd.conf is still the same, and permission has changed to 777

thanks
Do you have something like this in your httpd.conf?

<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
Podcast節目
AIRLOG podcast
SNAPPLE LAB 實驗試管
AIRLOG podcast在iTMS上的列表
頭像
luisehsu
留言破百
文章: 147
註冊時間: 07/04/2001 1:01 am
來自: Nowhere to Nowhere
聯繫:

Re: CGI configuration on Apache

#10 文章 luisehsu »

fddi1 寫: Do you have something like this in your httpd.conf?

<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
well
in httpd.conf, this is the global setup:
<Directory />
Options -All -Multiviews
AllowOverride None
Order deny,allow
Deny from all
</Directory>

and for cgi-bin dir:
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
AddHandler cgi-script .cgi
<Directory /var/www/cgi-bin>
AllowOverride All
Options ExecCGI
</Directory>

thanks
Fortune favors the bold.
- Virgil (70 BC - 19 BC)
頭像
digdog
討論區管理員
文章: 1297
註冊時間: 05/02/2001 1:01 am
聯繫:

Re: CGI configuration on Apache

#11 文章 digdog »

你的 cgi 第一行是長這樣嗎?

代碼: 選擇全部

#!/usr/bin/perl -w
你裝了其他版本的 Perl 嗎?
頭像
luisehsu
留言破百
文章: 147
註冊時間: 07/04/2001 1:01 am
來自: Nowhere to Nowhere
聯繫:

Re: CGI configuration on Apache

#12 文章 luisehsu »

digdog 寫:你的 cgi 第一行是長這樣嗎?

代碼: 選擇全部

#!/usr/bin/perl -w
你裝了其他版本的 Perl 嗎?
yes
that's exactly the first line of my test script and the location of perl
my perl version:
This is perl, v5.8.0 built for i386-linux-thread-multi

thanks
Fortune favors the bold.
- Virgil (70 BC - 19 BC)
頭像
digdog
討論區管理員
文章: 1297
註冊時間: 05/02/2001 1:01 am
聯繫:

Re: CGI configuration on Apache

#13 文章 digdog »

luisehsu 寫: yes
that's exactly the first line of my test script and the location of perl
my perl version:
This is perl, v5.8.0 built for i386-linux-thread-multi

thanks
我猜啦,是你的 perl 出了問題。要不要先 % perl -V 看看?
頭像
luisehsu
留言破百
文章: 147
註冊時間: 07/04/2001 1:01 am
來自: Nowhere to Nowhere
聯繫:

Re: CGI configuration on Apache

#14 文章 luisehsu »

digdog 寫: 我猜啦,是你的 perl 出了問題。要不要先 % perl -V 看看?
shouldn't be
in httpd.conf there are 2 dir set for cgi script:
/var/www/cgi-bin
/var/www/perl

the same test.cgi has no problem while located in /perl, but error message while in /cgi-bin

thanks
Fortune favors the bold.
- Virgil (70 BC - 19 BC)
fddi1
留言破百
文章: 188
註冊時間: 05/03/2001 1:01 am
來自: USA/Seattle, WA
聯繫:

Re: CGI configuration on Apache

#15 文章 fddi1 »

In your globala setup, replace this section:

<Directory />
Options -All -Multiviews
AllowOverride None
Order deny,allow
Deny from all
</Directory>

with this section:

<Directory />
Options -All -Multiviews
AllowOverride None
Order deny,allow
Allow from all
</Directory>
Podcast節目
AIRLOG podcast
SNAPPLE LAB 實驗試管
AIRLOG podcast在iTMS上的列表
頭像
luisehsu
留言破百
文章: 147
註冊時間: 07/04/2001 1:01 am
來自: Nowhere to Nowhere
聯繫:

Re: CGI configuration on Apache

#16 文章 luisehsu »

謝謝各位的幫忙
終於搞定了

發現除了global directory setting的問題之外
suexec的setup也有問題
所以即使httpd.conf的設定都沒錯
cgi還是沒有辦法在指定的目錄下執行(ex. user's home dir)

apache的說明文件中指出suexec並非default installed
但是似乎mandrake並不這樣想
害我搞了半天
目前是按照apache的說明建議把suexec拿掉

文件中沒有說明how to configure suexec after compilation
還是只有重新configure and compile一途?
謝謝
Fortune favors the bold.
- Virgil (70 BC - 19 BC)
頭像
digdog
討論區管理員
文章: 1297
註冊時間: 05/02/2001 1:01 am
聯繫:

Re: CGI configuration on Apache

#17 文章 digdog »

luisehsu 寫: 文件中沒有說明how to configure suexec after compilation
還是只有重新configure and compile一途?
謝謝
說到 suEXEC,那就要請你看這裡啦!(雖然是給 OS X 的,不過不無小補)
頭像
luisehsu
留言破百
文章: 147
註冊時間: 07/04/2001 1:01 am
來自: Nowhere to Nowhere
聯繫:

Re: CGI configuration on Apache

#18 文章 luisehsu »

digdog 寫:
luisehsu 寫: 文件中沒有說明how to configure suexec after compilation
還是只有重新configure and compile一途?
謝謝
說到 suEXEC,那就要請你看這裡啦!(雖然是給 OS X 的,不過不無小補)
糟糕
中文造詣太差
讓digdog以為我是用平假名(還是片假名?).....

日文不通啊! :oops:
Fortune favors the bold.
- Virgil (70 BC - 19 BC)
回覆文章