Novell Home

Getting Started with Novell AMP Server - Part 2

Novell Cool Solutions: Feature
By Jeff Fischer

Digg This - Slashdot This

Posted: 14 Jan 2004

This article is the second part of a series about developing with Novell AMP server. In the last article, Getting Started with Novell AMP Server, I walked through the setup of the Novell AMP server with NetWare 6.5, so you can have an AMP server installed. In this section, I will detail configurations of Apache Web server, MySQL database server, and PHP scripting language, as well as talk about how to manage a Novell AMP server through eDirectory.

Apache: A Choice Web Server

Over the past few years, as the Internet has grown from a fad to a business necessity, network administrators have had the task of building the infrastructure of company web sites. The most popular web server choice is the Apache web server. Over the past few years, I've seen several numbers for the market share percentage that Apache owns ranging from 35% to almost 90% and I don't know which one to believe. But I don't really care about the market share percentage. What I do know is that Apache is the most popular choice for web servers today with the largest market share and has been year over year for several years.

Businesses everywhere have implemented the Apache web server as their core web server. While Apache has many advantages and a few downsides as well, it has proven to be one of the fastest serving web servers on the market, most secure, most reliable, and most scalable. Finally it has one of the lowest if not lowest total cost of ownership numbers of any web server on the market-- thanks to the free open source project from the Apache Foundation. With reasons like these, one would even question why anyone would choose anything else.

No matter the platform in your company web production infrastructure, you can run the Apache web server. While Linux and many Unix flavors are the most popular choices for most companies, NetWare, Windows, and Macintosh are also available as viable options.

In fact, tests inside Novell have shown that Apache Web server performance on NetWare closely matches Apache Web server performance on Linux. While Linux does have a slight performance advantage over NetWare, I would not hesitate to put the Apache web server on a Linux or NetWare server in a production environment.

One thing that Apache has never claimed to be is easy to use. Many people, especially those who come from a graphical interface world, may find that Apache is difficult to setup and configure, especially if you have several web servers supporting your company web infrastructure.

Most people don't like to change configuration files, but prefer to have an administration console that can give them an easy to use configuration tool for their servers. Most companies, especially enterprise level companies such as Novell, will have multiple Apache Web servers hosting the company web site as well as the company intranet.

This is where Novell has given an advantage to running the Apache web server on NetWare. Novell has integrated the Apache Web server configuration into Novell eDirectory so your web server can be administratered easily through already existing eDirectory tools such as Novell ConsoleOne. And the other nice feature about this is that you can administer multiple Apache web servers just as easily as one web servers, even on multiple operating system platforms, without having to touch the configuration files for every web server on your network. This allows a company to easily take advantage of the flexibility of an Apache Web server infrastructure, without the headache of Apache Web server configuration. Let's take a closer look at how to do this.

Apache Manager

Apache Manger, a new Web-based administration tool included with NetWare 6.5, offers a simple GUI alternative to the httpd.conf file, making it easier to manage Apache. But Apache Manager is more than a simple GUI for the httpd.conf file. Using the Multiple Server Administration mode, you can manage multiple installations of Apache running on multiple servers in your network. This is sometimes referred to as a server farm. And because Apache Manager is a Java application, it is platform independent. Each Apache Web server you want to administer must have the Apache Manager installed. For information about installing the Apache Manager on Windows and Linux, see the Novell Documentation page at

Apache Manager includes two interfaces: Single Server Administration and Multiple Server Administration. The first interface is used to manage a single instance of the Apache Web server at a time. The second interface is best used if you are running multiple instances of Apache and want to consolidate the configuration changes you make.

The Apache Manager leverages eDirectory for its data store. Objects are created in the Directory to represent the Apache configuration information. The properties of the objects fill in the data to configure Apache, such as the directives that are entered in the httpd.conf file. Each Apache Web server has an object created in the Directory as well that represents the Apache web server. Each module is an object in the Directory as well. This allows for each Apache server on the network to be easily and centrally administered from one location.


MySQL is a database server that really doesn't need any introduction. MySQL is a fast, secure, reliable database server which many companies rely upon for their database transactions. MySQL is also open source and included with NetWare. The license included for MySQL with NetWare is a commercial license which removes any restrictions and license fees from anyone who uses MySQL as the database server for their applications.

The developers of MySQL have decided to keep MySQL fast and stable by not building in as many features as other enterprise level database servers, such as Oracle and Sybase. While MySQL 4.x included with NetWare does not support such features as triggers and other advanced features, it is a fully functional, relational database server.

While MySQL runs on many platforms such as Windows, Unix, Linux, MySQL on NetWare does have a few advantages. First, MySQL on NetWare supports Novell Cluster Services, a proven clustering technology, so you can cluster your database applications for increased reliability and scalability. This includes dynamic failover support so when one server goes down, another server automatically takes over. This is an excellent solution for mission critical applications that require around the clock uptime.

MySQL on NetWare supports all the traditional development interfaces such as JDBC, ODBC, scripting languages such as PHP, Perl, and of course C/C++ so you can develop your database solution to meet the needs of your enterprise and have the rock solid stability and speed of NetWare.

Another benefit worth mentioning is that when you install NetWare 6.5 and MySQL, you have the option to install Tomcast, which is integrated into Apache with the Mod_JK connector, and Novell eXtend Application. So you can have a light weight servlet container such as Tomcast, or a heavyweight J2EE certified Application server in the eXtend Application server. This further gives you the options you need for your enterprise solution. This gives you the ability to access your database from EJB, servlets, JSP, PHP, Perl, and C/C++.

If you don't use a DBMS to manage your MySQL server, you can use the MySQL Monitor which is also included with the MySQL server for NetWare. It gives you access to the MySQL server through SQL commands. You can enter SQL commands to insert, update or select information from the database. To run the MySQL Monitor on NetWare type mysql at the NetWare console prompt. A default installation of MySQL will open the monitor. Typically, you would disable anonymous access to your MySQL server in which case you will need to specify a username to open the monitor. The -u swith allows you to specify a username to login to the MySQL monitor.

MySQL configuration is the same on NetWare as on other platforms. The my.cnf file is located in the sys:/etc directory. This is the main file used to configure custom options for the MySQL server.

To manually startup the MySQL database server on NetWare, type in the following command at the server prompt:

mysqladmin -u  password <user's_password>


PHP, which stands for PHP Hypertext Preprocessor, is a powerful, easy to learn scripting language. It is considered a dynamic web page technology just like JSP or ASP. PHP offers a developer all of the power and flexibility of JSP, with the ease of learning of ASP. It does not require the memory and processing power of JSP, and does not contain the platform dependency of ASP. In my personal opinion, it is an excellent combination of the strengths necessary to develop powerful dynamic web pages quickly and easily.

Just like other dynamic web languages, you mix PHP code with HTML to create your web page. You delimit your PHP code from your HTML and can even output HTML directly from your PHP code.

While I do not intend to make this section a complete PHP tutorial, I will point out some differences between PHP and Java for example, for those who may not be familiar with PHP and want to get started developing web pages in PHP.

Benefits of PHP

There are many benefits to using PHP as the language for web development. First of all, you don't have any compatibility problems as you do with Java, such as which JVM version is installed on your machine. PHP is a server side scripting language, which helps to avoid those compatibility issues. Also, the client or browser, will never see the PHP code because it is processed at the server and only the HTML is delivered to the client. Also, since PHP is server side, the client does not have to worry about processing the page and puts a reduced load on the client.

Next, as a developer, you have access to all of the server side resources, such as databases, server resources such as environment variables, disk space, and others. Finally, PHP is free and open source, which means the community develops it, supports it, and enhances it. You don't need a commercial IDE to develop in PHP. Most people I know just use a text editor.

PHP includes an extensive set of libraries. PHP applications commonly leverage databases, such as MySQL. PHP also has libraries for PostgreSQL, MS-SQL, DB2, Informix, Sybase, the ODBC interface, and other databases as well. Just as an example, you can develop PHP applications that leverage services with LDAP, databases, SNMP, FTP, NNTP, HTTP, IMAP, POP3, COM, CORBA, XML, XSLT, sessions, SSL, Java, .NET, Apache, and many others. For a more detailed listing of language support, see the PHP documentation at PHP can even be object oriented or procedural, depending on your need.

A Look into PHP

Let's begin with a look into some of the features of PHP. Let's begin by talking about PHP variables, arrays, and functions, then moving to more advanced features.

Declaring Variables

As with any programming language, variables are used to store data inside memory. PHP, unlike other languages, is a loosely typed language, meaning that you don't have to worry about the data type of your variable. You don't even have to declare a variable type, when you declare a variable. There is no type checking in PHP, or actually it is probably more correct to say that there is very minimal type checking. PHP decides for you what type the variable is when you give the variable a value.

Variable Scoping

When using functions in your program, you should be aware of the scope of variables used within it. This refers to the availability of a variable specified within a function. You need to remember the following points with respect to variables in PHP. First, the scope of a variable is limited to the function in which it has been used. As a result, the variable is accessible, or available for use, only within the function and not elsewhere. As soon as you specify a variable within a function, this variable becomes local to the function in which it is introduced after the function is declared. This is also the case with Java and C++.

In summary, a variable declared within a function is available for use only within that particular function. In addition, a variable declared outside a function cannot be accessed by the function. This is different from Java and C++. This feature is useful because it prevents the contents of a variable from being overwritten if you use the same variable name more than once and assign different values to it. It also requires a little different way of thinking and planning to not declare a variable you need outside of the function and expect to have access to the variable inside the function. Consider the following code:

  function display ()
      $a = "I love PHP";
  print $a;

The value of the variable $a is assigned within the function display. Therefore, if you try to print the variable outside the function, the output will be blank because PHP treats the variable outside the function as a different variable to which a value hasn't been assigned.

Also notice that PHP does not prevent you from using the same variable outside the function because it is an entirely new variable. The value of the variable outside the function is just treated as a new variable whose value has not been specified. Java would not let you do this, and it would be considered very bad practice to do this in C++ also.

Scoping: The Global Statement

The ability to only access variables within their defined scope creates a limitation, since in many cases you may need to access a variable of higher scope than a function. You can use the global statement to access variables that are not defined within the function. Consider the following example:

  $favorite = "PHP";
  function display()
      echo "I love writing $favorite scripts!", "\n";

The variable $favorite is defined before declaring the function display. Therefore, the value specified in the variable $favorite will not be accessible within the function. When you try to access the variable $favorite in the function, the program assumes that $favorite is a new variable that doesn't have any value assigned to it. As a result, the string "PHP," which is assigned to the variable, will not appear in the output. The output would only be I love writing scripts!

The value of the variable $favorite is interpreted as null and an additional blank space appears in the output. You can resolve such problems by using the global statement.

Consider this example where the global statement is used:

  $favorite = "PHP";
  function display ()
      global $favorite;
      echo "I love writing $favorite scripts!", "\n";
  display ();

Again, the value of the variable $favorite is specified outside the function. However, you are using the global statement followed by the name of the variable within the function. As soon as you specify the variable to be a global variable, it becomes accessible inside the function. The output of the code is: I love writing PHP scripts!

Now, the word PHP is also printed. This value was assigned to the variable outside the function but was accessible within the function because you used the global statement.

Also, be aware, that you could change the value of the global variable within a function. Be careful when you use this.

One possible solution to this problem, depending on your situation, could be the use of the static statement. Static in PHP works the same as in Java and C++. The variable stays alive through the function and does not lose its value when the function goes out of scope.


There are a few main rules to consider when you create a function. First, you specify a function with the keyword function, the name of the function and parameters around the variables. Next, you do not need to define a function before it is used, as you do in Java and C++. PHP does not care about type checking, and does not need to be aware of the function signature beforehand in order to process the function. Also, PHP does not support function overloading. You cannot define a different function by using the same function name and changing the parameters of the function.

In PHP, you can call functions dynamically. You must follow 3 steps to do so.

  1. Declare a function.

  2. Then declare a variable and assign the function name to the variable (as a string in quotes).

  3. Then use the variable as a function.

The following code shows how functions are called dynamically:

  function addition ($a, $b)
      echo ($a + $b), "\n";
  $result = "addition";
  $result (3,6);

A function named addition is declared. Next, a variable $result is declared and is assigned the name of the function (as a string). Finally, you call the function addition using the variable $result. When you call the function, you actually use the variable $result as a function. The output of the code is: 9, just as expected. As is evident from the output, the values of the arguments $a and $b that were passed to the function addition are added together. However, you actually called the function by using $result, a variable.

Enumerated Arrays

Arrays that are numerically indexed are called enumerated arrays. The first index that represents the first element of a numerically indexed array is always 0. To understand this, consider the following code, which shows two ways to declare an array:

  $testarray[0] = "FirstItem";
  $testarray[1] = "SecondItem";
  $testarray[2] = "ThirdItem";
  $testarray[3] = "FourthItem";
  $testarray = array ("FirstItem", "SecondItem". ThirdItem", "FourthI  tem");

As you can see, the index numbers for each of the elements are not specified in the second example, so PHP takes care of that for you.

The foreach statement is the control structure you can use to loop through an array. Look at the following example to see how to do this in PHP.

  $emp_det []= "Brad";
  $emp_det []="Sally";
  $emp_det []="Robin";
  $emp_det []="Dave";
  $emp_det []="Bryan";
  $emp_det []="Garry";
          foreach ($emp_det as $temp)
             echo "$temp", "\n";

In this code an array named $emp_det is created and it stores the names of six employees. The foreach statement is used to loop through this array by temporarily storing the value of emp_det in a temporary variable named $temp. Each of the values present in emp_det is stored in $temp one after the other. Finally, when we print $temp, each element that was present in $emp_det is printed one after the other. The output is:

Associative Arrays

Arrays that are indexed by using strings are called associative arrays. When you use them, you specify a string instead of numbers within the square brackets. This would be like using a map data structure or a set in Java or C++.

Indexing arrays with strings is very useful at times. Typically, you would index arrays with strings if the data that you want to hold in the array consists of both numeric values and strings. Consider an example of creating an array that holds employee details. It would not be a good idea to use an enumerated array for this purpose because accessing data using numbers could be difficult. Consider the following code:

  $emp_det [Name] = "Jeff";
  $emp_det [Age] = "24";
  $emp_det [Code] = "8545";
  $emp_det [Designation] = "System Administrator";

In this code each element can be referenced using the string index associated with the element. For example, to access the element "Jeff", you can specify:

  echo $emp_det [Name];
  // This will print the string "Jeff"

A few array elements also hold numeric values such as "Age" and "Code". This suggests that you can use names (strings) or numbers as elements when you use associative arrays. Associative arrays can also be created using the array () function. Creating an associative array using the array () function is slightly different. For associative arrays, the string that you use as the index is called the key, and you assign a value to this key. Both the key and the value must be specified when creating an associative array. Consider the following example in which an associative array is created using the array () function:

 $emp_det = array (Name => "Jeff", Age => "24", Code => "System Admin  istrator")

In this code, the values for each element are defined in a single statement using the array() function. The => symbol is used to assign a value to the array. The string values are specified within double quotes. The key and the value are specified for each element of the array.

Looping through Associative Arrays is just the same as looping through enumerated arrays. The foreach statement is used with a slight change. You need to specify the key as well as the value of an element to access a particular element. Check out this example.

  $emp_det = array (
                     Name => "Jeff",
                     Age => "24" ,
                     Code => "8545",
                     Designation => "System Administrator");
  foreach ($emp_det as $key=>$temp)
            echo "$key = $temp","\n";

In this code $emp_det is the name of the array that stores the details of Jeff. The keys used in this array are Name, Age, Code, and Designation. The foreach statement is used to loop through this array. The variables $key and $temp are temporary variables that store the key and value, respectively. The loop is executed until all the details are printed one after the other. The output is:

  Name = Jeff
  Age = 24
  Code = 8545
  Designation = System Administrator

Multidimensional Arrays

PHP supports the use of multidimensional arrays. By using multidimensional arrays in PHP, you can create more complex data structures. Check out the following code.

  $emp_det = array (
                  array (Name=> "Dave", Code=> "8545", Hobby=> "Playing
  the guitar"),
                  array (Name=> "Sally", Code=> "8963", Hobby=> "Reading books"),
                  array (Name=> "Robin", Code=> "1030", Hobby=> "Trekking"),
                  array (Name=> "Brad", Code=> "3319", Hobby=> "Singing"),
  ) ;
  echo $emp_det [0] [Hobby];

In this code an array named emp_det is created. This array consists of four associative arrays of three elements each. The output of that code is: Playing the guitar.

It is evident from the output that the value of the third element of the first array is accessed and printed to the screen. In this example, the array $emp_det is an enumerated array that consists of four associative arrays. Each of these associative arrays consists of three elements. The echo statement is used to access the third element of the first associative array within the array $emp_det.

Here is an example of looping through a multidimensional array.

  $emp_det = array (
                 array (Name=> "Dave", Code=> "8545", Hobby=> "Playing  the guitar
                 array (Name=> "Sally", Code=> "8963", Hobby=> "Readin  g books"),
                 array (Name=> "Robin", Code=> "1030", Hobby=> "Trekki  ng"),
                 array (Name=> "Brad", Code=> "3319", Hobby=> "Singing  "),
  foreach ($emp_det as $tempone)
          foreach ($tempone as $key=>$temptwo)
                  echo "$key: $temptwo", "\n";
          echo "\n";

In this code two foreach statements have been used. The value of $emp_det is temporarily stored in $tempone. $emp_det is an enumerated array that contains associative arrays. Then, the value of $tempone is temporarily stored in the temporary variables $key and $temptwo because the arrays specified with the $emp_det array are associative arrays. The output is:
  Name: Dave
  Code: 8545
  Hobby: Playing the guitar
  Name: Sally
  Code: 8963
  Hobby: Reading books
  Name: Robin
  Code: 1030
  Hobby: Trekking
  Name: Brad
  Code: 3319
  Hobby: Singing

Object Oriented PHP

PHP does support object oriented programming. Here's how a class is defined and used in PHP.

  class class_name
       var $property_1;
       var $property_2;
       var $property_n;
  function some_function_name()
       //some code

Identifying Attributes and Functions

Attributes are characteristics that are specified in a class. Although attributes can be specified anywhere in the body of a class, it is preferable to specify them at the beginning of the class for clarity. An attribute can be of any scalar data type. In the example of the vehicle class, the brand name, number of wheels, and seating capacity features are attributes.

Let's create this class in PHP with the following code:

  class vehicle
  var $brand_name;
  var $number_of_wheels;
  var $seating_capacity;
   function repair()
      echo "The vehicle has been sent for repair";

The vehicle class has three attributes, $brand_name, $number_of_wheels, and $seating_capacity. The attributes are preceded with the var keyword. This class also has one function called repair which merely prints to the screen that the vehicle has been sent to be repair.

Creating an Object

After you create a class, you can begin creating objects of that class. Any number of objects can be created on the basis of an existing class. Objects are created and instantiated with the new statement using the following syntax:

 $object_name = new class_name;

The following code shows how objects are created:

  class employee
      var $emp_code;
      var $name;
      var $address;
      var $department;
      var $sex;
      var $date_of_birth;
      var $salary;
  $dave = new employee;
  $alice = new employee;
  echo gettype ($dave)," \n";
  echo gettype ($alice), " \n";

In this code, a class named employee is created. Two objects, $dave, and $alice, are created as instances of the employee class. The gettype () function is used to accept an argument and return the data type of the argument. In this case, the gettype () function is used to verify that you created the objects successfully. The output of the code shows that you have created two objects:

Accessing the Attributes of a Class by Using Functions

In a class, attributes and functions can coexist, and the attribute specified within the class can be accessed by a function specified within the same class. In a class, you can also refer to the currently instantiated object. This mechanism is simple and is of immense use with PHP. A class designates a special variable to the currently instantiated object. This special variable is $this, which can be used with the -> operator to access class attributes. Consider the following code to understand this concept:

  class employee
      var $emp_code;
      var $name;
      var $address;
      var $department;
      var $sex;
      var $date_of_birth;
      var $salary;
        function showsalary ()
              echo "Your salary is accessible from within this function.\n";
              echo "Your salary is :",$this->salary," \n";
  $jeff = new employee;
  $jeff->name="Jeff Fischer";
  $jeff->address="114, Novell Place";
  $jeff->department="Software Development";
  $jeff->salary="7500";  //I wish that was my monthly salary

In the preceding code, a class named employee is declared. The attribute $salary is defined in the employee class. The function showsalary () is added to the class and is used to display the salary of the current object. The $this->salary in the function signifies that this function will access the value assigned to the attribute >salary. The object $jeff is instantiated for the employee class and used to call the function defined within the employee class. The output is:
  Your salary is accessible from within this function.
  Your salary is :7500


PHP supports the use of constructors as well. Consider the following code:

  class employee
      var $emp_code;
      var $name;
      var $address;
      var $department;
      var $sex;
      var $date_of_birth;
      var $salary;
      function employee($empname)
         $this->emp_code="default value";
         $this->address="default value";
         $this->department="default value";
         $this->sex="default value";
         $this->date_of_birth="default value";
         $this->salary="default value";
  $jeff = new employee("Jeff Fischer");
  echo "Let's print the values assigned by the constructor.\n";
  echo "Employee Code:",$jeff->emp_code," \n";
  echo "Name:",$jeff->name," \n";
  echo "Address:",$jeff->address," \n";
  echo "Department:",$jeff->department," \n";
  echo "Sex:",$jeff->sex," \n";
  echo "Salary:",$jeff->salary," \n";
  echo "Date of Birth:",$jeff->date_of_birth," \n";

In this code, the class employee is created. All the attributes for the employee class are created. The constructor employee () is defined, and variable $empname is passed as an argument to this function. The $this->emp_code = "default value" statements are used within this function to assign default values to various attributes. The object $jeff of the employee class is created. This time, the value for the argument in the employee constructor is also specified at the time of instantiation because the name of the class and the name of the function are the same, making the function a constructor.

The constructor employee () accepts the argument $empname and changes the value of the name attribute for the newly created object $jeff to Jeff Fischer. The remaining attributes for the $jeff object now store the default value.

The output shows that the object was instantiated successfully and that the object function or constructor is also called during instantiation:

  Let's print the values assigned by the constructor.
  Employee Code:default value
  Name:Jeff Fischer
  Address:default value
  Department:default value
  Sex:default value
  Salary:default value
  Date of Birth:default value


There are 4 simple steps to connect to an LDAP Directory such as eDirectory.

  1. Connect using the ldap_connect function to the LDAP server. You specify the IP address or hostname of the LDAP server to connect to.
  2. You bind to the LDAP server using a username and password. If you do not, you will login anonymously.
  3. Perform operations you want such as searches, adding objects, renaming objects, deleting objects and so on.
  4. As always, you must clean up after yourself by closing the LDAP connection you created. Here is some sample code to search for users in an eDirectory tree.
   $ds = ldap_connect("") or die("unable to connect"); 
$bind = ldap_bind($ds, "cn=admin,o=jdev", "novell") or die("unable to bind"); 
$sr = ldap_search($ds, "o=jdev", "uid=*"); 
echo "number of entries returned is ".ldap_count_entries($ds, $sr).""; 
$info = ldap_get_entries($ds, $sr); 
for ($i=0; $i<$info["count"]; $i++) 
  echo "dn is: ".$info[$i]["dn"] .""; 

The output of this script is:

number of entries returned is 17

  dn is: cn=admin,o=jdev
  dn is: cn=brystinson,o=jdev
  dn is: cn=cvaldez,o=jdev
  dn is: cn=dtnelson,o=jdev
  dn is: cn=eliebing,o=jdev
  dn is: cn=jfischer,o=jdev
  dn is: cn=jlloyd,o=jdev
  dn is: cn=kneff,o=jdev
  dn is: cn=lyndsie,o=jdev
  dn is: cn=madair,o=jdev
  dn is: cn=mbarnum,o=jdev
  dn is: cn=NISUser,o=jdev
  dn is: cn=rjrodrig,o=jdev
  dn is: cn=rlsmith,o=jdev
  dn is: cn=rrjohnson,o=jdev
  dn is: cn=rrousseau,o=jdev
  dn is: cn=ypeterson,o=jdev

In conclusion, PHP is a great technology to use to develop web applications. It is powerful, easy to learn, and fast. In this article, we have discussed some of the basic configurations for the Novell AMP server and given some PHP examples. Good luck as you play with this.

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© 2014 Novell