Showing posts with label Apache2. Show all posts
Showing posts with label Apache2. Show all posts

Saturday, February 13, 2010

Solaris 10: Using CGI on Apache2 for beginners


Abstract: There are many helpful books and web-pages to assist beginning CGI programmers. Unfortunately most assume that one is uploading their files to a professionally administered server. This blog is aimed at those who have full access to a stock Solaris 10/Apache2 webserver.

Step 1: Enable Apache2 according to this post.

2: Login as super-user.

3: Change the cgi-bin folder permissions.

# chmod 775 /var/
apache2/cgi-bin


4: Save a valid cgi file to the ../cgi-bin directory. My test file is "first.cgi" which is borrowed from the excellent tutorial "CGI Programming 101" by Jaqueline Hamilton.
#!/usr/bin/perl -wT 
print "Content-type: text/html\n\n";

print "Hello, world!\n";

5: Set the file permissions.

# chmod 755 ..cgi-bin/first.cgi

6: Access your website to test the file.

http://your-site.net/cgi-bin/first.cgi

You should see "Hello World" on a plain background (or whatever your test file specified should happen).

Notes:

Solaris 10 comes with Apache and Apache2 installed (but inactive). Ensure that you don't confuse them (i.e. saving files in the wrong directories).

Apache2 does not require .cgi at the end of CGI files but does require the full file name when running it in a browser.

Wednesday, November 11, 2009

Solaris 10: Configuring a Stock Apache Server


Solaris 10: Configuring a Stock Apache Server

Abstract:

Sun had been a tremendous advocate of Open Standards for decades. One of the most influential standards advocated by Sun had been Hyper Text Transfer Protocol, or "http". This protocol is most often served by a server program, called a "daemon". Many people and organizations create "httpd" servers, one such group is the "Apache Software Foundation", where employees from Sun had been elected to the board, and members of the board had served in authoritative positions on other Sun open source projects. The "httpd" daemon from "Apache", one of the most popular http servers in the world today, is bundled into Sun's Solaris Operating System.

Identifying the Apache Service:

Solaris 10 comes shipped with an HTTP server, but it is disabled by default. The services infrastructure shows the server, even if you are uncertain how to identify the service.
Ultra2/root$ svcs apache2
STATE STIME FMRI
disabled 17:01:42 svc:/network/http:apache2

Ultra2/root$ svcs http
STATE STIME FMRI
disabled 17:01:42 svc:/network/http:apache2

Configuring the Apache Service

The Apache "httpd" server uses a configuration file, which must be minimally configured, before it will operate.
Ultra2/root$ cp /etc/apache2/httpd.conf-example /etc/apache2/httpd.conf

Ultra2/root$
vi /etc/apache2/httpd.conf
...
ServerAdmin user@fully.qualified.domain
...
ServerName fully.qualified.domain
...

Enabling the Apache Service

The service can be enabled in Solaris 10 via the Service Administration command.
Ultra2/root$ svcadm enable svc:/network/http:apache2

Ultra2/root$ svcs apache2
STATE STIME FMRI
online 1:07:55 svc:/network/http:apache2

Document Location

Documents are located in the following UNIX directory tree:
Ultra2/root$ ls -al /var/apache2/htdocs/index.html* | head
-rw-r--r-- 1 root bin 1663 Nov 21 2004 /var/apache2/htdocs/index.html.ca
-rw-r--r-- 1 root bin 1583 Nov 21 2004 /var/apache2/htdocs/index.html.cz.iso8859-2
-rw-r--r-- 1 root bin 2202 Nov 21 2004 /var/apache2/htdocs/index.html.de
-rw-r--r-- 1 root bin 1508 Nov 21 2004 /var/apache2/htdocs/index.html.dk
-rw-r--r-- 1 root bin 1828 Nov 21 2004 /var/apache2/htdocs/index.html.ee
...