Go Back   The macosxhints Forums > OS X Help Requests > UNIX - Newcomers



Reply
 
Thread Tools Rating: Thread Rating: 7 votes, 5.00 average. Display Modes
Old 08-08-2002, 08:04 AM   #1
mexx
Prospect
 
Join Date: Jun 2002
Posts: 11
forbidden, no cgi permission

hi...

I have a problem with permissions for cgi-scripts on MacOS X Server. When I want to run it, I only get this message: [Forbidden You don't have permission to access /cgi-bin/printenv]

I searched the forum but can't find an answer to this.

Things I've done:
CGI is active in the Server Admin Preferences
all possible permissions for the cgi-file tested

what could it be?

I've read in the Admin Guide (pdf. doc) that I have to set some permissions for the www-group. How can I do that?

Thanx for your help.

Btw: the printenv is a cgi-script that comes with the installation of OSX Server. I also tried to rename it to printenv.cgi or printenv.pl, but no change.

Last edited by mexx; 08-08-2002 at 08:24 AM.
mexx is offline   Reply With Quote
Old 08-08-2002, 09:09 AM   #2
takayuki
Prospect
 
Join Date: Aug 2002
Posts: 11
check this link out: http://forums.macosxhints.com/showth...&threadid=4522

You may find some good stuff there. I'm flailing in earnest at this point myself...

takayuki
takayuki is offline   Reply With Quote
Old 08-08-2002, 09:31 AM   #3
cedmond
Prospect
 
Join Date: Jan 2002
Posts: 1
Permissions

You may need to check the permissions of the actual cgi-bin/ directory also.

It may be helpful if you post what your permissions and user & group info looks like for these directories.
cedmond is offline   Reply With Quote
Old 08-08-2002, 11:16 AM   #4
vickishome
MVP
 
Join Date: Jul 2002
Location: Texas
Posts: 1,075
I created my own "cheatsheet" with the instructions on how to use SSI and CGI Scripts locally on my Mac in the event I had to do it all over again when I upgraded to Jaguar. I just edited them to make them a bit more complete (instead of just my shorthand) in hopes it would be helpful to others. Please keep in mind that I may have something wrong in this! I'm just a beginner! But, hopefully, I captured the info I was given accurately enough for this to be helpful.

Since I use both, SSIs and CGI Scripts, I have the instructions mixed together. I'm not going to try to separate them. So this will turn on both.

This info comes with many thanks to Erik (eriklager) and Merv (mervTormel) spent a considerable amount of time walking me through these steps.

Quote:
1. Turn Web Sharing ON in your System Preferences.


2. Edit the configuration file: /etc/httpd/httpd.conf

* Uncomment these lines (some may already be uncommented):

LoadModule includes_module libexec/httpd/mod_include.so
AddModule mod_include.c
AddType text/html .shtml
AddHandler server-parsed .shtml
LoadModule cgi_module libexec/httpd/mod_cgi.so
AddModule mod_cgi.c
AddHandler cgi-script .cgi

* Change this line:

FROM:
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
Options Indexes FollowSymLinks MultiViews

TO:
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
Options FollowSymLinks MultiViews Includes ExecCGI

* If you use .pl as your extention for your Perl scripts, change this line:

FROM:
AddHandler cgi-script .cgi

TO:
AddHandler cgi-script .pl

* If you use .html as your extension instead of .shtml, change this line:

FROM:
AddHandler server-parsed .shtml

TO:
AddHandler server-parsed .html

* If you use an .htaccess file, change this line:

FROM:
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride None

TO:
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride All

* If your scripts reside in a subdirectory other than /Library/WebServer/CGI-Executables/, then do a global search/replace to the path of your cgi-bin folder. For example, if your cgi scripts are in /Library/WebServer/Documents/cgi-bin, then make the following change:

FROM:
/Library/WebServer/CGI-Executables

TO:
/Library/WebServer/Documents/cgi-bin
(note: do not add an / at the end of the path.)

* If you use cgi-local instead of cgi-bin, do a global search/replace::

FROM:
/Library/WebServer/Documents/cgi-bin

TO:
/Library/WebServer/Documents/cgi-local

AND change "Options None" to "Options ExecCGI"

FROM:
<Directory "/Library/WebServer/Documents/cgi-local">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

TO:
<Directory "/Library/WebServer/Documents/cgi-local">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

* If the path you're using for your website is not /Library/WebServer/Documents, do a global search/replace on the path. For example, if the path to your website is /u/web/website, change

FROM:
/Library/WebServer/Documents

TO:
/u/web/website (change this path to match the path to your website)


3. Make the index.html file and the folder it resides in readable by everyone or user/group www.

Select the folder containing the site in the Finder, press Command-I, go to the Privileges section, add read-only rights to everyone and apply to all enclosed folders (but be careful with "Apply to all enclosed folders" if you have files in your site that require special privileges).


4. Make the Perl scripts executable:

Use "chmod +x" on the scripts. (For example, % chmod +x *.cgi)


5. Restart apache

Just stop and then start web sharing in the Sharing preference pane (in System Preferences).

OR

% sudo apachectl restart


6. Make sure the Perl scripts are saved with Unix Line Breaks (as opposed to Macintosh Line Breaks).


7. To access your website, use this url in your browser:

http://localhost/index.html.

If you have placed your website in the ~/Sites directory, use this url in your browser (replace ~username with your username):

http://localhost/~username/index.html.


8. Additional Information:

* There are a bunch of files already in /Library/Webserver/Documents - That is just the Apache Welcome page. They may be deleted or placed in another folder.

* Check errors: % tail /var/log/httpd/error_log

__________________
Vicki
• 15" MacBook Pro 2.66GHz i7, Mavericks 10.9.1, 8GB RAM
• iPad 4G WiFi 64GB
• iPhone 5 64GB
• 15" MacBook Pro 2.4GHz, Tiger 10.4, 4GB RAM
• G5 Dual 2GHz, Panther 10.3, 1.5GB RAM
• G4 Dual 1GHz, Tiger 10.4, 1.5GB RAM

Using Macs since 1986!

Last edited by vickishome; 08-08-2002 at 05:38 PM.
vickishome is offline   Reply With Quote
Old 08-08-2002, 11:42 AM   #5
takayuki
Prospect
 
Join Date: Aug 2002
Posts: 11
thanks!

Great post! Reading through your earlier thread (many thanks to Eric and Merv) on setting up the server to run perl and ssi, and your help on finding the httpd.conf file, I just got my perl scripts running in /Library/WebServer/CGI-Executables.

As I was configuring the httpd.conf document I was taking notes thinking wouldn't it be nice to have all of this on one cheat sheet.

Thanks again,

takayuki
takayuki is offline   Reply With Quote
Old 08-08-2002, 11:57 AM   #6
takayuki
Prospect
 
Join Date: Aug 2002
Posts: 11
Mexx,

I'm not sure what directory you are trying to run the scripts from, but I

Can run scripts from: /Library/WebServer/CGI-Executables

But cannot (forbidden to) run scripts from: Users/myusername/Sites/cgi-bin

Which directory are you attempting to run scripts from?

Can anyone shed any light on this? I know perl *.cgi scripts will run because they are working in the /Library/WebServer/CGI-Executables, but am forbidden to run scripts in the Users/myusername/Sites/cgi-bin. I set the cgi-bin permissions to 775 (from 755). But nothing.

thanks,

takayuki
takayuki is offline   Reply With Quote
Old 08-08-2002, 12:07 PM   #7
vickishome
MVP
 
Join Date: Jul 2002
Location: Texas
Posts: 1,075
I missed a change I had made (I'll update the info above later - gotta run for now).

Look in your httpd.conf for this path: "/Library/WebServer/CGI-Executables/"

Change it to the path in which your scripts reside. I believe it's in the config file in 2 places (just did a real fast look).

Let me know if that works.
__________________
Vicki
• 15" MacBook Pro 2.66GHz i7, Mavericks 10.9.1, 8GB RAM
• iPad 4G WiFi 64GB
• iPhone 5 64GB
• 15" MacBook Pro 2.4GHz, Tiger 10.4, 4GB RAM
• G5 Dual 2GHz, Panther 10.3, 1.5GB RAM
• G4 Dual 1GHz, Tiger 10.4, 1.5GB RAM

Using Macs since 1986!
vickishome is offline   Reply With Quote
Old 08-08-2002, 12:26 PM   #8
takayuki
Prospect
 
Join Date: Aug 2002
Posts: 11
I'll try your suggestion.

Can I configure it to run cgi's in more than one directory?

ex. /Library/WebServer/CGI-Executables/
and Sites/username/cgi-bin ??

thanks,

takayuki
takayuki is offline   Reply With Quote
Old 08-08-2002, 05:44 PM   #9
vickishome
MVP
 
Join Date: Jul 2002
Location: Texas
Posts: 1,075
I changed the instructions I had posted so you might want to double check it now. I obtained a backup of my original httpd.conf file, and used the instructions to make the changes, and then compared that result with the httpd.conf I'm using now. Doing this, I caught a couple of things I needed to change. It should be correct now.
__________________
Vicki
• 15" MacBook Pro 2.66GHz i7, Mavericks 10.9.1, 8GB RAM
• iPad 4G WiFi 64GB
• iPhone 5 64GB
• 15" MacBook Pro 2.4GHz, Tiger 10.4, 4GB RAM
• G5 Dual 2GHz, Panther 10.3, 1.5GB RAM
• G4 Dual 1GHz, Tiger 10.4, 1.5GB RAM

Using Macs since 1986!
vickishome is offline   Reply With Quote
Old 08-08-2002, 10:20 PM   #10
mexx
Prospect
 
Join Date: Jun 2002
Posts: 11
Talking thanx a lot !

<- this shows exactly how I feel at the moment! Hey guys, thanx a lot, the cgi runs now perfectly. The Guide you've written, Vicki, helped me a lot, because you've listed all important points (also phat thanx to erik and merv).

Btw, it took me a long time to learn about setting the permission with chmod +x (point 4. in your guide). Well, I've read something similar in the forum, so I had an idea that I maybe have to change this in the terminal. Terminal? Belive me, it's the first time I used it (and I must say, it's really very powerful...)

(for all ultra newbies, like me: point 4.: to set permission: Type "chmod +x /Library/WebServer/CGI-Executables/scriptname.cgi" into the Terminal without the "" . For questions about the chmod, just type man chmod into the Terminal and you get an explanation of chmod.


mexx

Last edited by mexx; 08-09-2002 at 06:47 AM.
mexx is offline   Reply With Quote
Old 08-09-2002, 12:06 AM   #11
vickishome
MVP
 
Join Date: Jul 2002
Location: Texas
Posts: 1,075
That's how I felt the other day when it started working for me! I'm glad I was able to pass the help along.
__________________
Vicki
• 15" MacBook Pro 2.66GHz i7, Mavericks 10.9.1, 8GB RAM
• iPad 4G WiFi 64GB
• iPhone 5 64GB
• 15" MacBook Pro 2.4GHz, Tiger 10.4, 4GB RAM
• G5 Dual 2GHz, Panther 10.3, 1.5GB RAM
• G4 Dual 1GHz, Tiger 10.4, 1.5GB RAM

Using Macs since 1986!
vickishome is offline   Reply With Quote
Old 08-17-2002, 07:27 PM   #12
DougAdams
Triple-A Player
 
Join Date: Jan 2002
Posts: 67
Uh, symlink

Great info!

But I know I'm gonna forget how to use a symlink. My remote host uses cgi-bin, I use cgi-local. How do I write the symlink and in which directory do I put it?

Yes, I could look for it on my system now, but I guess I just want that secure feeling one gets from obtaining the right answer from a more experienced user

Thanks!
DougAdams is offline   Reply With Quote
Old 08-17-2002, 09:00 PM   #13
DougAdams
Triple-A Player
 
Join Date: Jan 2002
Posts: 67
Correction!

Regarding my symlink question above; what I meant to say was:

My remote host uses "#!/usr/local/bin/perl"
I use "#!usr/bin/perl".
DougAdams is offline   Reply With Quote
Old 08-17-2002, 09:30 PM   #14
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
Code:
% ln -s /usr/bin/perl /usr/local/bin/perl
read this as: create a soft-link /to-this-thing /name-it-this

depending on the file mode of your /usr/local/bin , you may need to sudo to accomplish this. check your work:

% ls -l /usr/local/bin/perl

lrwxr-xr-x 1 root wheel 13 Aug 17 18:21 /usr/local/bin/perl -> /usr/bin/perl
mervTormel is offline   Reply With Quote
Old 08-17-2002, 10:12 PM   #15
DougAdams
Triple-A Player
 
Join Date: Jan 2002
Posts: 67
Thank You!

Merv, as usual, you are the best.
DougAdams is offline   Reply With Quote
Old 01-26-2003, 03:35 AM   #16
gedalin
Prospect
 
Join Date: Jan 2002
Posts: 36
unable to cgi

I did everything as prescribed in vicki's list (except that the scripts reside in the default directory /Library/WebServer/CGI-Executables). the script first.pl (the one suggested by the Apache manual) works from the command line, but when trying to point my browser to
http://localhost/cgi-bin/first.pl I get

The server encountered an internal error or misconfiguration and was unable to complete your request.

tail -1 /var/log/httpd/error.log:
[Sun Jan 26 10:29:52 2003] [error] [client 127.0.0.1] Premature end of script headers: /Library/WebServer/CGI-Executables/first.pl

httpd.crash.log:

Date/Time: 2003-01-26 10:29:52 +0200
OS Version: 10.2.3 (Build 6G30)
Host: wind.bgu.ac.il

Command: httpd
PID: 1369

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

Thread 0 Crashed:
#0 0x00000000 in 0x0
#1 0x00011c08 in cleanup_pool_for_exec
#2 0x00011c24 in cleanup_pool_for_exec
#3 0x00011c6c in ap_cleanup_for_exec
#4 0x000f6120 in cgi_child
#5 0x00012468 in spawn_child_core
#6 0x000126f4 in ap_bspawn_child
#7 0x000f6390 in cgi_handler
#8 0x0000d0c8 in ap_invoke_handler
#9 0x00016e04 in process_request_internal
#10 0x00016e94 in ap_process_request
#11 0x00006688 in child_main
#12 0x000068fc in make_child
#13 0x00006c2c in perform_idle_server_maintenance
#14 0x00007190 in standalone_main
#15 0x00007828 in main
#16 0x000026e0 in _start
#17 0x00002560 in start

PPC Thread State:
srr0: 0x00000000 srr1: 0x4000d030 vrsave: 0x00000000
xer: 0x20000000 lr: 0x00011bcc ctr: 0x00000000 mq: 0x00000000
r0: 0x00000006 r1: 0xbfffb5b0 r2: 0x8fe116f8 r3: 0x00066458
r4: 0x00000000 r5: 0x00000022 r6: 0x00006573 r7: 0xfff69758
r8: 0x00000000 r9: 0x00000002 r10: 0x00003b60 r11: 0x00055ac0
r12: 0x00000000 r13: 0x00000000 r14: 0x00000000 r15: 0x00000000
r16: 0x00000000 r17: 0x00000000 r18: 0x00000000 r19: 0x00000000
r20: 0x00000000 r21: 0x00000000 r22: 0xffffffff r23: 0x000f60c0
r24: 0xbfffd890 r25: 0x00094e20 r26: 0x00000000 r27: 0x000968cb
r28: 0x00096d28 r29: 0xbfffd890 r30: 0x0007ce58 r31: 0x00011c54

Any help would be greatlt appreciated.

Michael
gedalin is offline   Reply With Quote
Old 01-26-2003, 12:17 PM   #17
gedalin
Prospect
 
Join Date: Jan 2002
Posts: 36
solved - mod_rendezvous

Disabling previously installed mod_rendezvous solved the problem.
gedalin is offline   Reply With Quote
Old 12-30-2003, 12:54 PM   #18
talus
Triple-A Player
 
Join Date: Jul 2002
Location: Victoria BC, Canada
Posts: 59
Thanks Everyone!!

I just have to say thank you to everyone that has been working on this (and I know I'm a year late). I have been trying to get this to work for four days and after readind articles on Webmonkey, O'Rielley (sp?) and everthing else I could find - THIS IS THE BEST PLACE for Mac heads.

Thanks to you all and Happy New Year!!
talus is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 03:44 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.