Can I run HTML docs and Perl scripts from outside the XAMPP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Can I run HTML docs and Perl scripts from outside the XAMPP

Postby JerryBr » 08. March 2020 14:51

Hello, I'm very much a newbie to XAMPP. I did search my question to see if there was any info on it ... I couldn't see any answer.

I don't want to conflate my development websites with xampp system stuff by having them located all under c:/xampp/
So, could I have for example :-

c:/myWebsites/<website>/html
c:/myWebsites/<website>/cgi-bin

For my called Perl scripts to run as normal with XAMPP, do I need to modify the httpd.conf document root to :-
c:/myWebsites/ ?

So the link to a Perl script would then read :-
http://localhost/myWebsites/<website>/cgi-bin ?

Am I over simplifying this or over-complicating it? I don't want to change the httpd.conf file without first asking advice.
JerryBr
 
Posts: 5
Joined: 08. March 2020 14:45
XAMPP version: v 3.2.1
Operating System: Windows 7 64 bit

Re: Can I run HTML docs and Perl scripts from outside the XA

Postby Altrea » 09. March 2020 07:17

Hi,

In theory you can place your scripts wherever you want. Apache is very customizable at this point.
But if you want to do some professional scripting stuff it might be an advantage to separate your testing/staging environment from your coding stuff.
That way you are free to implement some code versioning or code analysing tools and only push a software revision to stage you know has a minimum amount of quality.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11942
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Can I run HTML docs and Perl scripts from outside the XA

Postby JerryBr » 09. March 2020 15:05

Thank you Altrea for your prompt reply. I'm confident this is a really donkey thread for you, so thank you for your patience!

My thinking is to develop in directories completely outside of XAMPP to an acceptable quality. Thereby leaving XAMPP devoid of my stuff. Then upload the scripts to the bona-fide server (probably with some path changes).

At the moment though Altrea, I'm struggling to get http//:localhost on my PC to successfully point to my script anywhere outside of the default xampp/cgi-bin directory.
Do I need to modify that document root statement line in httpd.conf along the lines I described in my original post ?
JerryBr
 
Posts: 5
Joined: 08. March 2020 14:45
XAMPP version: v 3.2.1
Operating System: Windows 7 64 bit

Re: Can I run HTML docs and Perl scripts from outside the XA

Postby Nobbie » 09. March 2020 21:15

Yes, you have to modify DocumentRoot.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: Can I run HTML docs and Perl scripts from outside the XA

Postby JerryBr » 11. March 2020 03:35

Thanks Nobbie but modifying the documentRoot in httpd.conf makes no difference at all - my script still cannot be found by localhost.

My file structure
c:Websites/Test/cgi-bin/Test1.pl
c:Websites/Test/HTML/Test1.htm

The relevant Test1.htm link statement ...
<a href="http://localhost/Test/cgi-bin/Test1.pl">Test Perl program</a>

When link taken localhost server responds with Error 404 Object not found! page.

httpd.conf
# DocumentRoot "C:/xampp/htdocs" original directory changed to -
DocumentRoot "C:/Websites"

But of course this document root relates to HTML docs, not cgi-bin scripts.
JerryBr
 
Posts: 5
Joined: 08. March 2020 14:45
XAMPP version: v 3.2.1
Operating System: Windows 7 64 bit

Re: Can I run HTML docs and Perl scripts from outside the XA

Postby Altrea » 11. March 2020 07:09

You must have done something wrong.

I downloaded a fresh XAMPP 7.4.3 bundle
changed in httpf.conf only two lines from
Code: Select all
DocumentRoot "/xampp/htdocs"
<Directory "/xampp/htdocs">

to
Code: Select all
DocumentRoot "c:/Websites"
<Directory "c:/Websites">


i created two testfiles

C:\Websites\Test\cgi-bin\Test1.pl
Code: Select all
#!C:\xampp\perl\bin\perl.exe
# The above line is perl execution path in xampp
# The below line tells the browser, that this script will send html content.
# If you miss this line then it will show "malformed header from script" error.
print "Content-type: text/html\n\n";
print "Hello world."


C:\Websites\Test\HTML\Test1.htm
Code: Select all
<a href="http://localhost/Test/cgi-bin/Test1.pl">Test Perl program</a>


If i request Test1.htm and click on the hyperlink, the perl script is been executed without any problems.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11942
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Can I run HTML docs and Perl scripts from outside the XA

Postby JerryBr » 11. March 2020 22:18

Yep, you're right Altrea. I hadn't also modified the <directory statement.
It's working now. Thank you again for your help and patience.
JerryBr
 
Posts: 5
Joined: 08. March 2020 14:45
XAMPP version: v 3.2.1
Operating System: Windows 7 64 bit

Re: Can I run HTML docs and Perl scripts from outside the XA

Postby Altrea » 11. March 2020 23:23

If the Directory directive is not changed too, then you should get a HTTP status code 403, NOT 404
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11942
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Can I run HTML docs and Perl scripts from outside the XA

Postby JerryBr » 15. March 2020 03:18

I've just been reading up on utilising "Virtual hosts".
Interesting - sounds very good.
JerryBr
 
Posts: 5
Joined: 08. March 2020 14:45
XAMPP version: v 3.2.1
Operating System: Windows 7 64 bit


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 136 guests