How do I ignore the Perl shebang on Windows with Apache 2?

前端 未结 8 756
南方客
南方客 2020-11-29 08:31

I have set up a local Perl web environment on my Windows machine. The application I\'m working on is originally from a Linux server, and so the shebang for source .pl<

8条回答
  •  攒了一身酷
    2020-11-29 09:24

    How to use Linux shebang (#!/usr/bin/perl) when running Perl based web-site with {site-name} on localhost in Windows 10?

    This works for me:

    • XAMPP on localhost\{site-name} (C:\xampp\htdocs\{site-name})
    • independently installed Strawberry Perl (C:\Perl\perl\bin) because Perl included in XAMPP package is not satisfactory

    In default configuration you must use this shebang:

    #!C:\perl\perl\bin\perl.exe -IC:\xampp\htdocs\{site-name}
    

    Is it possible to include directory (after -I switch) permanently to @INC?

    Yes, you can do it by setting the PERLLIB or PERL5LIB environment variables. This works when running perl script from command line, but surprisingly it is ignored by apache server in XAMPP. However one of @INC directories (C:/Perl/perl/site/lib) is usually empty so you can make symbolic link to your web-site directory:

    mklink /D c:\perl\perl\site\lib C:\xampp\htdocs\{site-name}
    

    Now, you can use this shebang:

    #!C:\perl\perl\bin\perl.exe
    

    Moreover, you can create directory c:\usr\bin

    md c:\usr\bin
    

    and copy perl.exe from C:\perl\perl\bin\

    copy C:\perl\perl\bin\perl.exe c:\usr\bin\perl.exe
    

    (Another mklink trick is not working here from some reasons.)

    Finally, you can use Unix-styled shebang on Windows:

    #!/usr/bin/perl
    

提交回复
热议问题