Web services :: The configuration file ::
If you are running your own Linux system, you can install Apache as a standard httpd daemon server that will use port 80. (You have to do the installation when logged in as the system’s administrator – root account.) You will need to create user and group accounts for your web server (as described in your Linux manuals); the usernames ‘www’ or ‘nobody’ are conventional. The user entry that you create in your /etc/password file should be appropriate for a server – no password (so it is not possible to login on this account), and the shell set to /bin/false. The user and group number that you select have to be specified in the httpd.conf file. If you are only planning to play with Apache for learning purposes, you will find it easier to run Apache under one of your existing user identifiers with the server monitoring port 8080. The configure script, in /home/me/apache_1.3.27, allows you to define the Apache that you want. The script can be run, from the /home/me/apache_1.3.27 directory, as: ./configure --help Running the script with the --help command line parameter results in a listing of all the configuration options. In the disable-module part of this listing there is a table whose contents define the Apache that will be built by default. This table lists all the modules whose code is included in this Apache release and indicates whether they will be incorporated in the built version. The table data should be something like the following: access=yes actions=yes alias=yes asis=yes auth=yes auth_anon=no auth_db=no auth_dbm=no auth_digest=no autoindex=yes cern_meta=no cgi=yes digest=no dir=yes env=yes example=no expires=no headers=no imap=yes include=yes info=no log_agent=no log_config=yes log_referer=no mime=yes mime_magic=no mmap_static=no negotiation=yes proxy=no rewrite=no setenvif=yes so=no speling=no status=yes unique_id=no userdir=yes usertrack=no vhost_alias=no (Documentation relating to each of these modules is available in the manual subdirectory of your installation, or online at http://httpd.apache.org/docs/mod/.) Modules that are not included by default can be added, and default modules may be dropped. When you have chosen the modules that you require, you can run the configure script with command line arguments that specify the directory where the working Apache system is to be created and specifying your changes to the default module list. For example, the following command would identify the /local/apache directory as the location where the web server system should be installed, drop support for user directories with web resources, and enable HTTP authorization with the dbm system being used to store username and password data. ./configure --prefix=/local/apache \ --disable-module=userdir \ --enable-module=auth_dbm (If you were creating an ‘official’ Apache on Linux, you would define additional options such as the account and group under which the server is to run.) There are many other options that can be used to change things such as the location of the logs directory, or the cache files for a proxy server. The next two steps are: make make install The first does all the compilation and linkage of executables; the second copies files and directories into your deployment directory (as specified via the --prefix argument for the configure script) which for these examples is /local/apache. The /local/apache directory on a Linux/Unix system should contain: bin The directory with the httpd executable, support programs like htpasswd, and scripts. cgi-bin This should contain two demonstration scripts (perl and sh) that echo environment variables (you may find it necessary to change the access permissions for these files before you can run the scripts). htdocs – A welcome page in several European languages. – Subdirectory with Apache manual. conf Configuration files. The configuration files include the httpd.conf file along with an original unedited distribution version (http.conf.default). The httpd.conf file has changes such as the inclusion of data defining the actual installation directories, and other adjustments that reflect the options chosen at the configuration stage. While there are many options in the configuration file that you will want to change, the installed system should be capable of being run directly. The ‘out-of-the-box’ configured Apache can be run by: On Windows: Start/Programs/Apache Web Server/Start Apache On Linux/Unix: /local/apache/bin/apachectl start When your Apache has started, you can contact it via a browser aimed at http:// localhost or http//localhost:8080. Apache should display a welcome page. This is actually a demonstration of HTTP content negotiation; there are several versions of the welcome page in different languages. If you exit your browser, restart it and set a language preference and then again contact your Apache, you should be able to get versions of the welcome page in French, Spanish, Italian etc. You should also be able to test run the CGI programs printenv (a Perl script) and test-cgi: http://localhost:8080/cgi-bin/test-cgi (if these demonstration CGI programs don’t run, check the access and execution permissions as set in the cgi-bin directory). On Linux/Unix, you can view the processes that are running using the command ps -ef | fgrep httpd (the ps command gets a listing of all processes, the fgrep filter picks those running the httpd executable). This should show ten processes running Apaches for you (a chief and nine tribesmen). The number is determined by default parameters in the httpd.conf file. You should shut down your Apache tribe before experimenting with changes to the settings in the httpd.conf file. Your Apache process group can be closed down via the Linux/Unix command /local/apache/bin/apachectl stop, or via the Stop Apache option in the Windows popup menu. On Linux/Unix, it is possible to change the configuration file and get Apache to change over to the new settings without requiring a full shutdown. If you use the apachectl restart command, the Apache chief reads the new options; it terminates all tribesmen and creates new ones that work with the new options (any working tribesmen are allowed to finish their current activities before they are terminated). An httpd.conf file consists of directives interspersed amongst a lot of explanatory comment. The possible directives are documented at http://httpd.apache.org/docs/mod/ directives.html. Some directives are simple one line commands, like the AddHandler directive that notifies Apache that files with a particular extension have to be processed in some special manner (via a ‘Handler’): AddHandler cgi-script .cgi Other directives, like the Directory directive, take multiple subdirectives. These directives have a start directive tag, a body and an end directive tag: <Directory "/local/apache/htdocs"> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow, deny Allow from all </Directory> Their effect is to limit the scope of the grouped subdirectives. You should read through the auto-generated httpd.conf file prior to attempting any changes. The first few directives set the global environment for your Apache tribe. The first important directive is the one that specifies the installation directory, e.g. ServerRoot "C:/Program Files/Apache Group/Apache" (Irrespective of platform, Apache code uses “/” as the separator character for directory pathnames.) The installer program will have filled in the value for ServerRoot. The next two directives identify files used for housekeeping data – such as the scoreboard file that is employed on systems that don’t support shared memory segments. The next few directives set values for controls such as the timeouts on connections, and limits on the number of requests a child process can handle. The Linux/Unix file will have directives that set the limits on the number of server processes, number to create at startup etc.; the Windows configuration file will simply have a limit on the number of threads in the second process (this is effectively the equivalent to the MaxClients control). If you will be running your Apache system on a typical home PC (Linux orWindows OSs), you will probably want to reduce the values for all those parameters. The Linux/Unix file next contains a single example related to the setting up of shared objects – dynamic linking in the Unix world. The corresponding part in the Windows httpd.conf file is longer; it has commented out LoadModule directives for important optional modules. For example, if you want to support requests concerning the server status, you should uncomment the LoadModule status_module directive. The next group of directives, starting with the Port 80 directive, set parameters for the Apache chief. If you are setting up a real httpd process on Linux, you may need to change the values in the User and Group directives, and you will also need to specify your email address in the ServerAdmin directive. These directives can be ignored if you are simply running a toy Apache system for learning purposes. If you are setting up a real Apache server, you will also need DNS set up; toy servers can be run with the ServerName directive specifying 127.0.0.1 or localhost. The next few directives specify the locations of components like the main directories used for HTML documents and CGI programs. They also set default access permissions that will apply to all directories unless specifically overridden by subsequent directives (as added by you). The main example here is for the htdocs directory; this should be something like: <Directory "C:/Program Files/Apache Group/Apache/htdocs"> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow, deny Allow from all </Directory> Directory, File and Location directives group other directives. The Options directive allows for the following controls: All Enable all options except MultiViews. ExecCGI Allow execution of CGI scripts in this directory (location). Includes, IncludesNoEXEC Enable processing of server-side includes for appropriate files in this directory. Indexes If user requests a directory, and there is no suitable directory index file (whose name would be defined elsewhere using a DirectoryIndex directive), then a list of files should be returned. MultiViews Enables content negotiation. FollowSymLinks, SymLinksIfOwnersMatch Enable the use of ‘links’ in a Unix file system. In this example, the defaults for htdocs and its subdirectories are set to allow clients to view the contents of a directory (as a page with a list of files, or something prettier), enable support for content negotiation, and permit the use of Unix inter-directory links. |
legal disclaimer
Our website is not responsible for the information contained by this article. Web-articles is a free articles resource.
Suggestion: If you need fresh, daily updated content for your website, feel free to use our service. Click here for more information.
related articles
Internal employee blogs can be a fantastic catalyst within your company. Internal employee blogs help forge connections inside the company. External employee blogs are also great because they allow employees to connect with like-minded individuals outside the company. It doesn’t matter whether you have a dozen employees or 2000, having your staff members connect creates fantastic new opportunities especially if you’re using idea blogs, as these pairings ...
The vBulletin Administrator Experience What are the differences for an administrator compared to a regular member? Well, there are quite a few. We'll take a look at some of the more important ones now. Forum and Thread Tools The first differences are the forum and thread tools. Forum tools allow the administrator to view the posts and attachments that are in the moderator queue. (These are the posts and attachments that need to be approved before being made visible.) Th...
3. Generation of dynamic pages
Most of this text is concerned with elaborate ways of creating dynamic pages through Perl scripts, PHP scripts, Java servlets and Java Server Pages. The basic Apache setup provides support for CGI programs (based on Perl scripts and alternatives), and for the fairly limited ‘server-side includes’ (SSI) mechanism. The relevant modules (mod_env, mod_cgi and mod_include) are included in the default Apache build. It is best to limit the number of directories that contain executable code that can generate dynamic pages. The...
4. Apache logs
Apache expects to maintain logs recording its work. In its standard configuration, Apache records all access attempts by clients and all server-side errors (subject to a minimum severity cutoff that is set by a control parameter). There is further provision for creation of custom logs. For example, you can arrange to log data identifying the browsers used (so, if you really want to know, you can find the proportions of your clients who use Opera, Netscape, IE or another browser). You should plan how to use the data from these ...
5. The next few elements define options
In this example, the defaults for htdocs and its subdirectories are set to allow clients to view the contents of a directory (as a page with a list of files, or something prettier), enable support for content negotiation, and permit the use of Unix inter-directory links. The next subdirective, AllowOverride, makes provision for overriding .htaccess files in subdirectories. The options here allow you to specify that nothing be changed (as in the example with AllowOverride None), or that anything be changed (AllowOverride Any...
6. Slightly modified specification for a CS1 program
The manager of a fast food outlet requires a program to help track sales. The outlet only serves burgers with fries; a burger meal costs $5.95. Customers may order any number of burger meals. The program is to help calculate prices of orders, and is also to keep records of total orders and the largest single order. The program is to use a simple menu-select style loop with the options: (1) Place order (2) Print totals so far (3) Quit The order option should result in a prompt for the number of meals ...
7. Lists and arrays
A few more features of Perl must be covered before any more interesting programs can be written. First, we need Perl’s ‘lists’ (or ‘arrays’). A Perl list is like a dynamic array class in C++ or Java (e.g. java.util.Vector). Lists do not use Perl’s object syntax, but a list is basically an object that owns data and which has an associated group of functions. A Perl list: Owns a collection of data elements (usually scalar values, but you can build lists of lists and other more complex struct...
8. Each output line consists of a list of words
These lines have to be sorted using an alphabetic ordering that uses the sub-string starting at the keyword. The keyword starts after column 50, so we require a special sort helper routine that picks out these sub-strings. The sort routine is similar to the numeric_sort illustrated earlier. It relies on the convention that, before the routine is called, the global variables $a and $b will have been assigned the two data elements (in this case report lines) that must be compared. sub by_keystr { my $str1 = substr($a...