Setting up Perl under Apache

I'm very disappointed with Apple over the very poor documentation and support for what is potentially an extremely valuable asset in the Mac OSX tool box i.e. being able to test Perl scripts locally using the Apache software included under OSX.
Because it's taken me 2 days to wade through the discussions here and find resources online I want to help others avoid my delays and post what I found. I would also like to comment that the unix community active on this list though so very helpful in many ways could resist scorning those who are entirely unfamiliar with terminal and the command line interface and try to condescend to explain in layman's terms what is essentially not that complex but is so shrouded in jargon, shorthand and arcana that it seems almost deliberately difficult to penetrate. I would ask Apple to please just post a simple 'how to' or if they see fit include this email in their FAQ's.
Thank you to the many who have posted on this subject on this list and I apologize if I have used your suggestions without personal credit. I am with this document merely giving back something of what I have taken out of this useful resource. Please feel free to offer amendments to any obvious mistakes or misunderstandings I am a novice at Unix attempting to help other novices because (Ibelieve) I still speak the same language.
This method is for starting Perl under Tiger OS 10.4x (may work for Panther or earlier I haven't tested it) on a desktop machine, not a server.
To start Apache under OSX
1) To turn on Apache just go to System prefs and turn on 'personal web sharing' under the 'sharing' control panel. Note the IP address that appears under the 'Select a service...' window as this is the IP address of your local web address or 'yourlocalhostaddress' (referenced below). This is what you type into the browser to view your pages locally.
2) It seems intuitive to place your web site in the user/yourusername/sites folder on your hard drive. While this is acceptable for basic web sites it seems to make configuration harder for Perl. I could not access a cgi-bin nor find documentation that satisfactorily informed me how to access a cgi-bin created in this location. That doesn't mean it's not possible just that I don't know how to do it.
Apple have created another folder with a pre-configured cgi folder at the following location;
yourharddrive/library/WebServer
Place your website in the 'Documents' folder and your Perl scripts in the 'CGI_Executables' folder. It's unnecessarily confusing to me that Apple have essentially renamed the cgi-bin to 'CGI_Executables' and the 'html' folder to 'documents' as they would be found under the Apache installation that I'm familiar with but that seems to be what's happened here.
To start Perl support in Apache under OSX
3) If you dont already have one it's useful to have an ultra simple Perl script on hand to test whether your configuration is working. More complex script such as formmail.pl may have additional settings that are confusing as to whether it's the file or the configuration that is causing a script error. To create a simple script copy and paste the following code;
#!/usr/bin/perl
print "Content-type: text/html\r\n\r\n";
print "Hello, World.";
into a new, empty document in a text editor and save it as 'first.pl' in your 'CGI_Executables' folder. You can open it in Safari using the following address;
http://yourlocalhostaddress/cgi-bin/first.pl
4) If you test your script now a call to the Perl script will merely open the page with the script as text and will not run it. This is because Apple supplies their copy of Apache with Perl disabled, it's necessary to edit a file called 'httpd.conf' in order to turn Perl on. The recommended way to turn this file on is using the terminal program but the file can also be located through the mac OS although it is partially hidden, it can be edited in a text editor that is suitable for coding such as BBEdit.
The best online documentation I found about how to edit the httpd.conf file using terminal is here;
http://www.macdevcenter.com/pub/a/mac/2001/12/14/apache_two.html?page=1
However I'm not sure that he is accurate (though I hesitate to disagree with the expert) my experience was significantly different see below(*).
Terminal has useful testing features but the command line is obscure and daunting to the novice. In addition UNIX programmers seem to delight in scaring away the cautious with silly, portentous warnings about privacy etc. This document is very sensitive to the way it's edited, however your computer will not blow up if you get it wrong and there is a back-up default version stored in the same folder so if you do screw up you can restore the defaults and start again.
If you wish to do it without going through the terminal the 'httpd.conf' file is located here;
/private/etc/httpd/httpd.conf
where private is an invisible folder so you cant navigate to it directly via the Mac OS. However if you copy and paste the above address into Safari's address bar the folder window will come up revealing the document (this is an undocumented feature and I discovered it by accident so use at your own risk). Alternatively you can navigate to it using an FTP program such as Transmit when you have 'show hidden files' turned on in the preferences. Transmit is a very useful tool because it also allows you to view and change the permissions (or CHMOD) of the files you view in the same manner as you would on a remote server. Something which you cannot do using the 'Get Info' on the Mac OS
You'll notice that there is an httpd.conf and an httpd.conf.default file. The latter is your backup so dont be overly scared of editing the first file, proceed with caution but not with trembling.
Once you have the program open in BBEdit (or your editor of choice) uncomment the following lines by deleting the # symbol;
#LoadModule perl_module libexec/httpd/libperl.so
#AddModule mod_perl.c
The quickest way to find these lines is to do a find on 'Perl' (something you cant do in Terminal). Dont change anything else just save and close, you will be required to enter your administrator password at this point.
(*)Please note;
Kevin Hemenway in the macdevcenter.com article says to uncomment the following lines;
#LoadModule cgi_module libexec/httpd/mod_cgi.so
#AddModule mod_cgi.c
And makes no mention of the lines ending in perl rather than CGI. His article is from 12/14/2001 so it may be out of date. In my httpd.conf file the lines ending 'cgi' were already uncommented but the lines ending 'perl' were commented out. I uncommented the lines ending 'perl' and now in my version both (cgi and perl) are uncommented and active. There are security implications to uncommenting any lines so I may have opened a security loophole that I'm not aware of however until I uncommented the 'perl' lines my scripts did not work. I would be grateful for an explanation of the implications from any Unix expert reading this.
5) The last thing you need to do is restart Apache so that it can load the new config file. To do this stop web sharing in the preferences pane and then restart it.
If you test your simple Perl script 'first.pl' now it should load and show the text "Hello World" in a browser window.
6) if you wish to load a more complex script and find that they will still not work, at least you know that Perl is working. You can check the error logs by opening the terminal and at the prompt (yourusername$) type;
tail /var/log/httpd/error_log
This enables you to trace the whether a permissions, configuration or other error has occurred.
WARNING;
The above is a distillation of my frustrating experience over the last 2 days, it details how I finally got it to work. With everything in scripting I find that I repeat the same method multiple times, convinced each time that I have it right and all of a sudden it works where it didn't work before. This always leaves me unsure that I may have inadvertently done some thing right (as logically I was obviously inadvertently doing something wrong before) that is not documented here. I offer this method as the product of my experience, because I hope it is helpful and because I have the confidence that there is a way to back out of it using the default config file. Despite the above use at your own risk.
G5 Dual 2.5Ghz + Pbook G4 867Mhz + 15GB iPod   Mac OS X (10.4.3)  

That sounds like a very good useful tip. I would hold on to it in your own computer's repository as well and post sections of it whenever you see someone needing help with it until you are able to add it to the contributions section of the User Tip forum here:
http://discussions.apple.com/category.jspa?categoryID=103

Similar Messages

  • Re: execution problem with oracle jsp under apache

    i followed the instruction to install oracle jsp running on apache 1.3.9 and apacheJServ/1.1b3 under win nt 4.0 with sp5. i created a servlet zone to hold the jsp file but for some reason it will not look the the dir specified in the jserv.conf. it look at the dir under apache document root dir.. therefore, i created a dir under the apache root dir and then it was able to compile the hellouser.jsp correctly. when i run lotto.jsp, the image files would not display. why?

    Apache Servlet zones allow you separate servlet (sets) into distinct classloaders. The OJSP servlet needs to exist in a servlet zone. However the content the OJSP servlet operates on (the .jsp file) lives in the document root directory just like your other web content. OJSP does support a configuration/init parameter whereby you can explicitly specify a physical directory other than what is mapped via the Apache settings. Please consult the documentation if you want to do this.
    As for why the lottery images aren't being displayed, more information is needed. The generated page should create local references to the images files. Are the images in where they are expected to be? Can you be more explicit about the URI you send and the physical structure of the Lottery sample in the file system?

  • Returning database query results under Apache Axis

    I'm trying to write a web service that will return the results of a standard database query. Does anyone have any pointers on what sort of data structure I should convert my ResultSet to that would be best suited to run under Apache Axis? Currently I am trying to use a String[][][], which Axis can serialize and encode fine, but seems to have problems decoding. If someone has some client-side source that is able to receive a String[][][], please post it, as I would rather not have to change the web services around if at all possible.

    According to IBM, the best way to do this is by returning an array of a complex type. Using this idea, I changed my services to return an array of DBRow objects, which I wrote for this purpose. DBRow is a simple class that contains a single private String[] with get and set accessors, in accordance with the JavaBeans standard. If you need more details, just respond to this topic.

  • Nice set of perl scripts for h264 encoding stuff

    I have found a nice set of perl script written for flexible h264 related encoding. They were originally developed for gentoo but they also run fine under Debian. I guess running them under arch will work as well.
    Here is the original thread over at the Gentoo Forum:
    http://forums.gentoo.org/viewtopic-t-74 … 444a855600
    Here is the webpage from the author plus a newly build install bash script which will download and install the encoding suite:
    http://blog.fangornsrealm.eu/
    May be someone likes to build a package ?
    I am not using arch this much the last few month. So I am kind of the wrong guy for building such a package
    -D$

    I have found a nice set of perl script written for flexible h264 related encoding. They were originally developed for gentoo but they also run fine under Debian. I guess running them under arch will work as well.
    Here is the original thread over at the Gentoo Forum:
    http://forums.gentoo.org/viewtopic-t-74 … 444a855600
    Here is the webpage from the author plus a newly build install bash script which will download and install the encoding suite:
    http://blog.fangornsrealm.eu/
    May be someone likes to build a package ?
    I am not using arch this much the last few month. So I am kind of the wrong guy for building such a package
    -D$

  • Tomcat running under apache

    Hi All,
    I want to be able to run my tomcat3.3.1a under apache webserver, and i klnow i have to use mod_jk. The problem i am having is that my tomcat is not producing the mod_jk.conf_auto file.
    I have even added the apacheconfig directive to server.xml but the file is not being generated.
    Any ideas anyone on how i can get this file generated.
    Thanks in advance
    Sajid

    I've tried the instructions from http://www.webmasterbase.com/article.php?pid=52&aid=305, and it's OK.

  • Our daughter just got an iPad Mini and I set it up for her, but I originally set it up under my apple id in order to create an apple id for her.  Is there any way for me to switch it to her account as the main user?

    Our daughter just got an iPad mini and I originally set it up under my Apple ID in order to create an Apple ID for her (she's under 13 so I set up iCloud family)... is there any way to switch the main user to her so that she can use iMessage and such under her own account?  When she uses iMessage it's my account.  I can't find a solution anywhere.  Thank you!!

    Hi Maudluna,
    I understand you would like to sign out your Apple ID from an iPad. You can do this easily by following the steps in the article below. I have also linked to an article about Family Sharing which can help you create and manage multiple accounts:
    iOS: Sign in with a different Apple ID in the iTunes Store, App Store, and iBooks Store - Apple Support
    Start or join a family group using Family Sharing - Apple Support
    Family Sharing makes it easy for up to six people in your family to share each other’s iTunes, iBooks, and App Store purchases without sharing accounts. Pay for family purchases with the same credit card and approve kids’ spending right from a parent’s device. And share photos, a family calendar, and more to help keep everyone connected.
    Thank you for contributing to Apple Support Communities.
    Take care,
    Bobby_D

  • How to I set an internal link in a PDF document using Preview?  After setting a link under the Tools/Annotations menu, the link doesn't work and no detailed instructions are provided.

    How to I set an internal link in a PDF document using Preview?  After setting a link under the Tools/Annotations menu, the link doesn't work and no detailed instructions are provided via the Help menu other than it showing the pull-down menu selection to make.

    No.  I am able to use the other features such as underlining, highlighting, adding rectangles and oval and save those changes.

  • Anyone manage to get ColdFusion to work under Apache on OS X 10.10 Yosemite?

    Hi all I'm having great difficulty getting ColdFusion10 to work under Apache with OS X 10.10 Yosemite.
    Here is a description of what I've faced and a little of what I've done to solve my problem
    Problem 1
    Apache httpd.conf file gets messed up
    Solution: copy original httpd.conf file from /etc/apache2/original/ to /etc/apache2/
    Problem 2
    No Java Virtual Machine is installed!
    Solution: install Java (version 6 or 7 is better) you may only be able to install version 8
    Problem 3
    ColdFusion doesn't know where your Java installation is so find and update your ColdFusion configuration files
    /Applications/ColdFusion10/cfusion/bin/jvm.config
    /Applications/ColdFusion10/cfusion/bin/coldfusion
    /Applications/ColdFusion10/cfusion/runtime/bin/wsconfig_jvm.config
    change the source to whatever your current Java is and where it's located
    for example if you have version 7 installed:
    /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
    if you have version 8 installed:
    /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
    Problem 4
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: YOUR PATH HERE!
    Solution:Still working on this one!

    I think you should try Pacifist http://www.charlessoft.com/
    It's a .pkg installer for OS X, I used it several times to install software that Apple's Installer can't install. After installing Xsan 1.0 from your CD, just launch Apple's software update to upgrade to version 1.3. I think it should work (I didn't try it with Xsan, but this procedure works with other software).
    Khafaga

  • Event 106-VMSwitch Error:Available processor sets of the underlying physical NICs belonging to the LBFO team...............

    I am Using Hyper-V 2012 R2. and the NIC Teaming mode is "Switch Independent (Dynamic)", I am getting the following Error on NIC Teaming on Both Hyper-V.
    Available processor sets of the underlying physical NICs belonging to the LBFO team NIC /DEVICE/{DBC60E38-B514-4752-941F-09E0418E6D87} (Friendly Name: Microsoft Network Adapter Multiplexor Driver) on switch DE3CB5B5-A67F-449F-83E4-A302671D9715 (Friendly
    Name: VSwitch) are not configured correctly. Reason: The processor sets overlap when LBFO is configured with sum-queue mode.
    Every Hyper-V has 2 NIC with 10GB (Broadcm) Teamed. and Hyper-V Specification is "16 Core , Socket 2, Logical Processor 32.
    Can ANy one Helps why I am getting this error and whats the solution to the Error....
    Thanksss...

    Hi Asfand,
    As you mentioned ,every hyper-v has 2 NICs and team mode is sum-queue .
    You can try to use following powershell command (if you want to allocate 14,16 LPs for each NIC and 0,1 LP for default queue ) :
    Set-NetAdapterVMQ -Name NIC1 -BaseProcessorgroup 0 –BaseProcessorNumber 2 -Enabled $True -MaxProcessorNumber 15 –MaxProcessors 14
    Set-NetAdapterVMQ -Name NIC2 -BaseProcessorgroup 0 –BaseProcessorNumber 16 -Enabled $True -MaxProcessorNumber 31 –MaxProcessors 16
    Please refer to the similar thread :
    http://social.technet.microsoft.com/Forums/en-US/1b320975-eb20-41a4-a06a-98bbff5a85db/hypervvmswitch-event-106?forum=winserverhyperv
    Best Regards
    Elton Ji
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Flex 2 + CF MX 7.0.2 under Apache

    I have been trying for almost 4 months to get Flex and CF
    7.0.2 to communicate with each other under Apache 2.2, but have
    gotten basically no-where. For example, I can't even get Ray
    Camden's Flex implementation to work, nor any of the CF wizard
    tutorials...or anything for that matter.
    Apache works. CF works. Flex works. CF works WITH Apache (so
    it says...after doing all the technotes and jdbc:mysql stuff) but
    Flex and CF won't communicate properly as regards reading any kind
    of data from a database.
    Under the CF wizard in Flex, for example, it tells me the
    only valid server root is WEB-INF/flex, on the install drive of
    CF...but that's not even on the same drive as Apache htdocs.
    Has anyone run across a tutorial on how to make this fly? I
    have basically used the ACME Guide, and dumped in Flex, as I've run
    into no instructions anywhere to cover adding Flex properly under a
    CF/Apache environment. I have tried every configuration I can think
    of, and completely formatted/reinstalled everything at least a
    dozen times since November.
    Any suggestions? Should I just dump Apache completely? I
    thought it was wrong to run CF/Flex on the web without it...
    Shawn

    You need to do the 7.01 update and then the 7.02 update.
    http://www.adobe.com/support/coldfusion/downloads_updates.html#mx7
    Ken Ford
    Adobe Community Expert
    Fordwebs, LLC
    http://www.fordwebs.com
    "gill1723" <[email protected]> wrote in
    message
    news:ekn3k5$8fa$[email protected]..
    >I installed coldfusion mx 7 and tried to update it and
    this is what I am
    > getting. We are running ms server 2003 with IIS, any
    suggestions
    >
    > Unsupported Version This is not a valid version of
    ColdFusion MX 7.0.1
    > (Server Configuration) or it is unsupported by the
    updater
    >

  • HT204408 This discussion does not answer my question. I set FaceTime up under the wrong email address (apple id.) I have 2 of them. How can I change it?

    I set FaceTime up under the wrong address. How can I change it to the correct one?

    On the menubar,  Facetime > Preferences > Account
    Regards,
    Captfred

  • When you buy a iPhone from some can you set it up under straight talk?

    If you buy a iPhone from someone can you set it up under straight talk?

    Doubt it. The phone will probably be locked to a specific carrier and you will be out of luck. I suggest just buying one brand new instead of someone else.

  • Perl and apache giving access denied message locally...

    I have a simple perl script that is sitting in my "sites" directory, and have turned on all the changes in the apache httpd.conf file.
    when I use http://localhost~username i get the default web page, but when I add the firct.cgi to the end, I get the following error...
    Forbidden
    You don't have permission to access /~kentjason/first.cgi on this server.
    why is this happening. I should be able to see anything in that directory, right?
    thanks alot,
    jason

    That was it! ok so what did that do? I thought the x
    property was for actual executables like safari
    etc...
    You need the executable bit set in any UNIX variant for a file that is executed directly. It could be a script or an actual executable binary. For example, if you tried to execute the file from the command line directly it would have given an error.ls -l test.pl
    -rw-r--r-- 1 joe staff 226 Jan 15 2003 test.plNote that the execute bit is not set. Now try to execute it from the command line like so:./test.pl
    -bash: ./test.pl: Permission deniedBut, you could execute it by calling perl directly and using the script as an argument.which perl
    /usr/bin/perlNote that perl's execute bit is set:ls -l /usr/bin/perl
    -rwxr-xr-x 1 root wheel 19280 Mar 20 2005 /usr/bin/perlSo, without changing the permissions on the script itself, it would run if you did it this way:perl test.plThe web server always tries to run CGI scripts directly, so in that case the execute bit must be set. For scripts that use interpreters like bash or perl, the "sh-bang" line (ie, #!/usr/bin/perl on line 1) tells the OS which interpreter to use when you execute it directly. You could leave that out, but then you'd need to run the script as an argument to the interpreter as mentioned above. Does that all make sense?
    Anyway, I'm glad you have it working and hope I didn't over complicate things with this explanation

  • My kids are linked to my itunes account. How do I set them up under their own accounts/credit cards without losing any of their music, apps etc?

    Basically there are 3 users , each with their own iphones using the same username, password and credit card to purchase stuff. I want to give one of them their own personal account and a different card but obviously keep their current songs. They are set up as 3 different users on a Windows PC. Thanks all!!!

    Welcome to the Apple Community.
    If your children are under 13, you should open 2 new accounts for yourself and let them use it. They can use these ID's for iCloud and so have their own email! contacts! calendars etc, but still share your original ID for iTunes for apps, music, etc. You can continue to sync them with your computer.

  • My Daughter has an Ipod and when I set up the account before giving her the gift for Xmas I set it up under my email address, now I have an iphone 4 and I want to have my own account for itunes. Is there any way 2 do this w/ two separate accts, same email

    My daughter got an Ipod for Xmas and I set up the apple account before hand & used my email address to set it up, now I have purchased an Iphone 4 and I want to have a separate itunes for my music.... is there a way to have two separate itunes accounts under the same email address?

    Thanks.  I have my iPad on my lap and her iPod in my hand. We can FaceTime each other but it won't let either of us message each other. I know mine is activated as I use it frequently. I have activated hers as well. Maybe I will put it in the too hard basket for tonight, sleep on it and try again tomorrow.

Maybe you are looking for

  • How to get Layer's visibility status?

    Ii I know the class name & UID of an item on a indd file, how can i get it's visibility status? I tried to do it like this as shown in a nexample, InterfacePtr<ISpreadLayer> spreadLayer(::GetDataBase(unknown), hierarchy -> GetLayerUID(), UseDefaultII

  • Adobe Flash Player 11.1 r102について

    OS:Windows Embedded環境で利用していたら.以下のエラーメッセージが出ました. これは何が原因なのでしょうか? (※バージョン:Adobe Flash Player 11は今は確認中です.) 使用開始してから.約3ヶ月経過して初めて出てきたエラーです. 何に問題があるのか?今後どうしたらこの問題が解決されるのか?が全く分からず相談しています. タイトル Adobe Flash Player 11.1 r102 has encountered a problem and needs

  • Newbie

    What is the best way to get started learning Java? I am I am very familiar with C++. Thanks in advanced.

  • Can't find wireless on Dell D620

    When I install the Oracle VM Server on a Dell D620 the kernel sees the eth0 direct attached ethernet but it does not see the eth1 wireless interface. Can I just plumb/configure/create this interface and have the kernel recognize the device or do I ne

  • Run vi in signal express

    can someone help me, i want to run a vi of labview in signalexpress but i don't get it...what must i do to do it, can someone give a tutorial or an example please??