Pages: Previous12
Current Page: 2 of 2
Re: How Can I make a valid cgi-bin directory
Posted by: morongo (---.an3.sac8.da.uu.net)
Date: August 14, 2006 11:36PM

I installed WAMP5 yesterday, php (and everything else) worked great!

So today I installed the perl add-on.

I read the stuff in this thread first, did the recommended httpd.conf changes and everything ran just fine, right from the start (you are all a great help, Thanks very much!).

The only thing I took exception to was having to put: "#!C:\wamp\perl\bin\perl.exe" at the top for the 'shebang' line...pretty clumsy and makes it difficult to just 'run' scripts with the usual shebangs of '/user/bin/perl' or '/user/local/bin/perl' (depending on your webhosts' path to perl).

Now, I run a win2k box at home and upload stuff to my server after I test it, so I'm using wamp for development and would like to keep the scripts/code the same as for my server enviroment, so here's what I did:

First, I downloaded a link utility from this site:
forge.novell.com/modules/xfmod/project/?ntfslink

Next, I created these empty directories on my drive:
C:\user\bin

Then, I installed ntfslink.exe and restarted my machine, as directed.

After rebooting, I ran windows-explorer to get to my local folders, navigated down to C:\user\bin and highlited the 'bin' folder then right-clicked on it.

The usual context-menu popped up and I navigated down the menu to the newly added NTFSlink selection.

I clicked on 'link folder', it asked me to choose a 'target' folder to link to and I navigated to \wamp\perl\bin and highlighted the 'bin' folder.

I then clicked OK and that was that, a symbolic link under win2k was created.

Back at my test perl-script, I changed the '#!C:/wamp/perl/bin/perl.exe' to: '#!/user/bin/perl'.

I ran firefox, browsed to: [localhost] and it came right up, so symbolic links *do* work in windows!

To be honest, I did quite a bit of research before deciding on this particular utility (there are several others out there) and I also read-up on the pros and cons of symbolic linking under Windows (and you should too...), but if you follow the above guidelines, you can have your scripts running with thier normal unix 'shebangs' without changing anything in your normal configuration under WAMP5/Apache, even on a Windows box.

If you're at all creative, you can see how this technique can be put to use to solve the above local cgi-bin directory issue, which started this thread.

NOTE: *never* delete a symbolic-link directory with windows-explorer or from the cmd-line, always remove the directory with the same utility that created it...you have been advised.

See this article for more in depth info:
[shell-shocked.org]

Ta,

Morongo



Post Edited (08-14-06 23:58)

Options: ReplyQuote
Re: How Can I make a valid cgi-bin directory
Posted by: yfastud (72.236.169.---)
Date: August 15, 2006 04:14PM


Options: ReplyQuote
Re: How Can I make a valid cgi-bin directory
Posted by: morongo (---.an1.sac8.da.uu.net)
Date: August 16, 2006 07:58PM

First, symbolic link functionality is already built-in to an NT-based OS, programs like ntfslink and others just let us access that feature more easily.

As for WAMP 'associations', the location of perl under C:\wamp\perl is just a convenience, it would work just as well if you installed perl in C:\perl, but there is still no easy way to intall the win-perl directory tree as C:\user\bin (so I use symlinks...which work admirably).

Now, as for local/independent cgi-bin directories for multiple users, here's how I do it:

Under c:\wamp\www create your user directories:
c:\wamp\www\user1
c:\wamp\www\user2

Under each user directory, create the cgi-bin directories:
c:\wamp\www\user1\cgi-bin
c:\wamp\www\user2\cgi-bin

Copy any convenient perl script into each cgi-bin directory.
To prove you're accessing JUST your own cgi-bin (and not aliasing the main apache2\cgi-bin), change the name of the perl files you just copied to user1.pl and user2.pl, respectively.
If you want, you can add: print "Using User1(or 2) cgi-bin\n"; to each file just for fun.


Now, go into httpd.conf, scroll to the bottom where the virtual stuff is located and edit the file to resemble this:

-----------------------------------------------------------

NameVirtualHost 127.0.0.1:80


<VirtualHost 127.0.0.1:80>
ServerAdmin webmaster@user1.com
DocumentRoot c:/wamp/www/user1
ServerName user1.com

ScriptAlias /cgi-bin/ "c:/wamp/www/user1/cgi-bin/"
<Directory "c:/wamp/www/user1/cgi-bin/">
AllowOverride All
Options Indexes FollowSymLinks Includes +ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 127.0.0.1:80>
ServerAdmin webmaster@user2.com
DocumentRoot c:/wamp/www/user2
ServerName user2.com

ScriptAlias /cgi-bin/ "c:/wamp/www/user2/cgi-bin/"
<Directory "c:/wamp/www/user2/cgi-bin/">
AllowOverride All
Options Indexes FollowSymLinks Includes +ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
------------------------------------------------------------

Save the file. Close your editor.

Don't restart Apache just yet...

Next, open the following as a text-file:
C:\WINNT\system32\drivers\etc\hosts

In the hosts file, enter something like this:

# localhost: Needs to stay like this to work
127.0.0.1 localhost
127.0.0.1 user1.com
127.0.0.1 user2.com

Save the file, Close your editor.

Restart Apache.

Open a NEW instance of your browser (so it re-reads the hosts file)
Browse to: [user1.com]
If you followed directions, it works.

If not, read this again and find out where you messed up.

Morongo


Options: ReplyQuote
Re: How Can I make a valid cgi-bin directory
Posted by: yfastud (---.cable.mindspring.com)
Date: August 18, 2006 12:00AM

Thanks Morongo for your very good tutor. I might try it when I have time. Besides, I still wonder a little bit as follows:

----------------------------------------------

NameVirtualHost 127.0.0.1:80


<VirtualHost 127.0.0.1:80>
ServerAdmin webmaster@user1.com
DocumentRoot c:/wamp/www/user1
ServerName user1.com

ScriptAlias /cgi-bin/ "c:/wamp/www/user1/cgi-bin/"
<Directory "c:/wamp/www/user1/cgi-bin/">
AllowOverride All
Options Indexes FollowSymLinks Includes +ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 127.0.0.1:80>
ServerAdmin webmaster@user2.com
DocumentRoot c:/wamp/www/user2
ServerName user2.com

ScriptAlias /cgi-bin/ "c:/wamp/www/user2/cgi-bin/"
<Directory "c:/wamp/www/user2/cgi-bin/">
AllowOverride All
Options Indexes FollowSymLinks Includes +ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

---------------------------------------------------------------

With the code above, the independent cgi-bin for multi-users already work, why you need to install ntfslink and have to do some extra work? What the benefit from it?

Options: ReplyQuote
Re: How Can I make a valid cgi-bin directory
Posted by: morongo (---.an1.sac8.da.uu.net)
Date: August 18, 2006 07:18AM

yfastud,

> why you need to install ntfslink and have to do some extra work?
>What the benefit from it?

I get to keep my perl-code the same on both my home machine and my web-server, which also runs under Apache, but on a BSD platform.

I only use ntfslink to simulate '/user/bin/perl' for perl scripts I write, I don't need it for multiple users or cgi-bin directories (as you pointed out above...).

It's not extra work either, ntfslink just adds a menu item to explorer's right-click context menu that Microsoft should have provided in the first place, the operating system already has the functionality, Microsoft just didn't give us a 'clickable' way to get at it.

Mark Russinovich and David Soloman over at sysinternals might give you a better explanation, check out this link (it's short):

[www.sysinternals.com]

Webmasters find this kind of thing 'handy' because they can 'mirror' their web-directories (including the directories outside their document-root) for developing pages and CGI-code on their home win-boxes.

morongo



Post Edited (08-18-06 07:50)

Options: ReplyQuote
Re: How Can I make a valid cgi-bin directory
Posted by: Skeeza (---.ipt.aol.com)
Date: August 19, 2006 12:52PM

Set this up and managed to get it working, it seemed quite handy but when it comes to installing subdirectories in user1/cgi-bin or user2/cgi-bin etc it doesn't work.

on my server i never run files right out of the cgi-bin and always use subdirectories.

Im sure this can be fixed but every time you want to add a new folder subdiretory in user1 or user2 cgi-bin i dont want to have to do all this again.


any ideas?

Options: ReplyQuote
Re: How Can I make a valid cgi-bin directory
Posted by: morongo (---.an3.sac8.da.uu.net)
Date: August 19, 2006 07:01PM

Skeeza,

I previously entered a long post about adding ScriptAliases to your Virtuals config without first TRYING my current configuration to see if it worked with subdirectories under cgi-bin...turns out it does, no further configuration changes required.

So I deleted that post to avoid the confusion.

According to my searches, Apache sudirectories DO inherit the congiuration of their parents, and that seems to be the case with my installation but apparently not with yours.

The only thing I can tink of is that there may be, and probably is, another difference between our two config files (maybe in the Globals area), that's hanging you up.

If you want to compare configs, let me know and I'll send you a copy of my httpd.conf.

morongo



Post Edited (08-19-06 20:35)

Options: ReplyQuote
Error Log says: Unable to spawn child proccess! HELP!
Posted by: Vald (---.dhcp.davl.vt.charter.com)
Date: August 30, 2006 06:37PM

I am having trouble with getting my scripts to work.

The majority of the scripts live in
www/protected/

how can I make scripts executable in this directory?

thanks

Options: ReplyQuote
Re: this is how
Posted by: Vald (---.dhcp.davl.vt.charter.com)
Date: August 30, 2006 07:23PM

Internal Server Error

cgi is working, but the scripts refer to other scripts and attempt to launch child processes unsuccessfully. I can move the "other scripts" to the cgi-bin directory, but then they won't read the correct paths to additional files. I actually need to make my /www/storepro5/protected/ directory capable of executing perl scripts. how do I do this?

thanks

val


Options: ReplyQuote
Re: How Can I make a valid cgi-bin directory
Posted by: CyberSpatium (67.170.181.---)
Date: August 30, 2006 08:18PM

edit your Options for your c:\wamp\www directory in your httpd.conf file and add +ExecCGI. save the file and restart apache to make your new settings take effect. by doing this you will be able to execute cgi scripts anywhere in your c:\wamp\www, including other directories below it. so, it will make your c:\wamp\/www\storepro5\protected directory to now use perl scripts. just make sure you point tot he correct location to perl.exe in the top of all your perl scripts.



Post Edited (08-31-06 02:09)

CyberSpatium
----------------------
WAMP Forum Admin

Web Development for Newbie's Blog - Check out my new blog. It is for web developers, and especially tailored for the web development newbie. If you are not fluent in “geek speak”, then this incredible resource is just you. And even if you are a web development pro, this is a great resource to check out some of the latest web development tips, news, tutorials, codes and more.

Options: ReplyQuote
Re: How Can I make a valid cgi-bin directory
Posted by: Vald (---.dhcp.davl.vt.charter.com)
Date: August 30, 2006 09:36PM

I have edited the files as you suggested, but I still get the

500 Internal Server Error

message.

here is what the log says.

[Wed Aug 30 15:34:58 2006] [error] [client 127.0.0.1] (OS 3)The system cannot find the path specified. : couldn't create child process: 720003: agora.cgi, referer: [localhost]
[Wed Aug 30 15:34:58 2006] [error] [client 127.0.0.1] (OS 3)The system cannot find the path specified. : couldn't spawn child process: C:/wamp/www/storepro5/agora.cgi, referer: [localhost]

Options: ReplyQuote
Re: How Can I make a valid cgi-bin directory
Posted by: CyberSpatium (67.170.181.---)
Date: August 31, 2006 02:10AM

did you enter everything correctly? here is an example

<Directory "c:/wamp/www">
AllowOverride All
Options Indexes FollowSymLinks Includes +ExecCGI
Order allow,deny
Allow from all
</Directory>

remeber to restart apache after you edit the httpd.conf file for the new settings to take effect.

Options: ReplyQuote
Re: How Can I make a valid cgi-bin directory
Posted by: tmc (---.hsd1.wa.comcast.net)
Date: September 06, 2006 07:30AM

Make sure to print this first in your Perl script:

"Content-type: text/html\n\n"

So your Perl code looks like this:

print "Content-type: text/html\n\n";

Options: ReplyQuote
Pages: Previous12
Current Page: 2 of 2


Sorry, only registered users may post in this forum.