Setting up a web server can be complicated, so OptiPerl provides an internal server. It is not optimized for speed, like most production servers, but for testing purposes.


It also does not need any set-up. The only thing it must know is the folder where the scripts you have are located.


To use the internal server do the following:


1) Enable menu Server / Internal server

2) Set it's Server root to the path where all your scripts are located.


To run all the included examples with optiperl, you must select menu Server / Change server root and select folder c:\program files\optiperl\webroot. (or accordingly were you installed optiperl).


Open now a script from the cgi-bin folder above. Make sure the option "Run with server" is enabled, and press "Run".


icon_exclaim If you don't see html output of the scripts, please read the "Possible errors" in the next section.


Notice the url sent to the browser; It is (where script.cgi the filename you opened).


Also try opening the test.html from c:\program files\optiperl\webroot. If you run it, the url called is


icon_arrow To conclude: When we set up the webroot to 


c:\program files\optiperl\webroot


  • the file

c:\program files\optiperl\webroot\test.htm

is called as


  • the file

c:\program files\optiperl\webroot\cgi-bin\test-form.cgi

is called as


  • If you try to open a file that is not under the webroot, you will get an error if you try to run it.


Also notice the form part of test.htm:


<form method="POST" action="/cgi-bin/test-form.cgi" name="PostForm">


The action part tells the browser what script to call to process the form. Since the form was called with, the browser adds the host part to the action above when pressing the submit button, and calls:



icon_arrow If we change the webroot to




  • the file


is called as


  • the file


is called as


  • Any other file not under c:\mywebs\mysite results in an error.


icon_arrow Notice that in all cases, after the host part ( the relative paths of the file compared to the webroot are appended.


The best thing to do is actually have your entire site offline, copying the directory structure, and setting as webroot the folder you copied all the files. This is important, so you can develop scripts and html pages that will work both offline and remotely, without any (or minimal) changes.


Let's assume your site is and you can access your site with an FTP program. From path / your entire site starts:






Copy all these files to a folder on your computer, like c:\mywebs\coolsite. Select as the internal server's webroot the folder c:\mywebs\coolsite.


icon_idea If you use html publishing software, then you already have your entire site offline. Select as webroot the folder containing all your files and subfolders of the site.


Now just like will send /index.html, the same thing will happen by calling or http://localhost/, without being connected to the internet. You can try loading index.html in optiperl and pressing run, or entering the above address in the Browser menu / URL and pressing "Go to url".


Let's assume index.html has a form that calls form.cgi. It could have something like:


<form method="POST" action="/cgi-bin/form.cgi" name="Form">


If the webroot of the internal server is correct, this will work on both servers without any change. When running, the browser will call after pressing "submit". On, the browser would call


Before setting the webroot, think how the url's would be translated. Suppose by error, we set the webroot to c:\mywebs\. Now index.html would have to be called as and the form.cgi as We would also have to change the Action in the html page to action="/coolsite/cgi-bin/form.cgi". All the above would work, but after uploading to, the html page would not work, since does not exist.


icon_exclaim However your site might have a different directory structure (like a different htdocs and cgi-bin folder), but OptiPerl can support any configuration using aliases. Read more in possible scenarios.



Top  Previous  Next