Using native Windows Binary (without admin rights)
-
Download one of binary from https://httpd.apache.org/docs/current/platform/windows.html#down
-
Unzip a portable version (zip file) into
C:\Apache24
-
cd
C:\Apache24\bin
and run httpd.exe -
Open browser to http://localhost
Press CTRL+C
to stop the server.
Where is the httpd.conf
?
The web server config file is located at C:\Apache24\conf\httpd.conf
The default document root should be at C:\Apache24\htdocs
The default error log file is at C:\Apache24\logs\error.log
How to enable cgi-bin scripts
There is a default perl
test script under
C:\Apache24\cgi-bin\printenv.pl
, and if you have native Windows Perl
installed, you need to modify the first line in the script. Example:
#!/C:/perl5/perl.exe
Now test it on http://localhost/cgi-bin/printenv.pl
Using Python as cgi-bin
test script
Create C:\Apache24\cgi-bin\printenv.py
script:
#!C:/Python36/python.exe
import cgi
cgi.test()
Test it on http://localhost/cgi-bin/printenv.py
Using Cygwin for Windows
-
Install
httpd
andhttpd-tool
packages in your cygwin -
If you have not started
cygserver
, run it now in the background. -
Run
apachectl -k start
-
Open browser to http://localhost
Run apachectl -k stop
to stop the server.
Where is the httpd.conf
?
The web server config file is located at /etc/httpd/conf/httpd.conf
The default document root should be at /srv/www/htdocs
The default error log file is at /var/log/httpd/error_log
How to enable cgi-bin scripts
-
Ensure you have installed
perl
package in Cygwin. -
Modify
/srv/www/cgi-bin/printenv
file first line with#!/usr/bin/perl
-
Run
chmod a+x
-
Modify
httpd.conf
to enablemod_cgi
:
<IfModule mpm_prefork_module>
LoadModule cgi_module modules/mod_cgi.so
</IfModule>
- Restart httpd server
Now test it on http://localhost/cgi-bin/printenv
You can also test the /srv/www/cgi-bin/test-cgi
script, but it uses
#!/usr/bin/sh
instead of perl
!
If you use default cgi-bin
folder that are setup with ScriptAlias
,
then you do not need to add Options +ExecCGI
line to the conf file.
Using Python as cgi-bin
test script
Create /srv/www/cgi-bin/printenv.py
script:
#!/usr/bin/python3
import cgi
cgi.test()