apache

A trail of 13 pages, marked with comments, by enjoylife
About this trail:

APXS is a Perl script that is created when you build the Apache web server from source. Chances are that if you are getting these errors and you obtained Apache as a binary distribution, that APXS is not configured correctly for your system. Your best bet is to get the Apache source from http://httpd.apache.org and build it yourself. Use the following for a basic build (read the Apache docs for other options):

[user@host] ~ $ cd /usr/local/src
[user@host] ~ $ gzip -dc apache_1.3.19.tar.gz|tar xvf -
[user@host] ~ $ cd apache_1.3.19
[user@host] ~ $ ./configure --prefix=/usr/local/apache \
[user@host] ~ $ --enable-module=most \
[user@host] ~ $ --enable-shared=max
[user@host] ~ $ make
[user@host] ~ $ make install

Note: The above steps assume that you downloaded the Apache source and placed it in your /usr/local/src directory.

13 marks in this trail
1

APXS is a Perl script that is created when you build the Apache web server from source. Chances are that if you are getting these errors and you obtained Apache as a binary distribution, that APXS is not configured correctly for your system. Your best bet is to get the Apache source from http://httpd.apache.org and build it yourself. Use the following for a basic build (read the Apache docs for other options):

[user@host] ~ $ cd /usr/local/src
[user@host] ~ $ gzip -dc apache_1.3.19.tar.gz|tar xvf -
[user@host] ~ $ cd apache_1.3.19
[user@host] ~ $ ./configure --prefix=/usr/local/apache \
[user@host] ~ $ --enable-module=most \
[user@host] ~ $ --enable-shared=max
[user@host] ~ $ make
[user@host] ~ $ make install

Note: The above steps assume that you downloaded the Apache source and placed it in your /usr/local/src directory.

2

I had the very same problem. This means that you
don't have cygserver installed. Apache2 requires
cygserver. See this thread on the Cygwin mailing
list:
http://www.cygwin.com/ml/cygwin-apps/2005-02/msg00085.html

There are a few steps to installing cygserver. First
of all, try typing in:
cygserver-config

If you get something like "command not found" then you
need to run Cygwin setup, go to Admin and find
cygserver. Install it.

Then go here:
http://www.cygwin.com/cygwin-ug-net/using-cygserver.html
and follow the directions which start at "How to
start Cygserver". They claim that installing
cygserver as an NT service is optional, but that
wasn't my experience. Be sure to make sure you have a
Windows environment variable called "CYGWIN" and that
it contains the word "server".

Then you just run:
cygserver-config

When it's finished, start the service :
net start cygserver

Then you should be able to start Apache with:
/usr/sbin/apachectl2 start


Good luck!

-Ethan Herdrick
www.herdrick.com

The service has been installed under LocalSystem account.
To start it, call `net start cygserver' or `cygrunsrv -S cygserver'.

Further configuration options are available by editing the configuration
file /etc/cygserver.conf.  Please read the inline information in that
file carefully. The best option for the start is to just leave it alone.

Please keep in mind, that a client application which wants to use
the services provided by cygserver *must* have the environment variable
CYGWIN set so that it contains the word "server".  So, if you don't
need any other special CYGWIN setting, just set it to "server".

It is advisable to add this setting to the Windows system environment.

Basic Cygserver configuration finished. Have fun!
4
Using apxs to create shared DLL modules

To make the extending httpd with shared DLL modules easier, you can use apxs.

Make sure you have configured $CFG_LDFLAGS_SHLIB within apxs to include the --shared directive and the path to the shared code DLL cyghttpd.dll.

After performing make install you will probably have the following lines within your apxs:

  # apxs
  [...]
  my $CFG_LD_SHLIB      = q(dllwrap --export-all --output-def libhttpd.def --implib libhttpd.a --driver-name gcc);          # substituted via Makefile.tmpl
  my $CFG_LDFLAGS_SHLIB = q(-g); # substituted via Makefile.tmpl 
  my $CFG_LIBS_SHLIB    = q();        # substituted via Makefile.tmpl 
  [...]
Change these to reflect the new compile options needed for shared DLL modules as follows:
  # apxs
  [...]
  my $CFG_LD_SHLIB      = q(gcc);          # substituted via Makefile.tmpl
  my $CFG_LDFLAGS_SHLIB = q(-g --shared); # substituted via Makefile.tmpl 
  my $CFG_LIBS_SHLIB    = q(/path/to/cyghttpd.dll);        # substituted via Makefile.tmpl 
  [...]

Now you should be able to create a shared DLL module from a mod_foo.c source file with:

  $ apxs -c mod_foo.c -o mod_foo.dll
Place the resulting DLL in Apache's libexec directory, so the dlopen() function within the compiled in mod_so.c module can find and load it at runtime.
5
   

Apache is controlled by a series of configuration files: httpd.conf, access.conf. and srm.conf (there's actually also a mime.types file, but you have to deal with that only when you're adding or removing MIME types from your server, which shouldn't be too often). The files contain instructions, called directives, that tell Apache how to run. Several companies offer GUI-based Apache front-ends, but it's easier to edit the configuration files by hand.

Remember to make back-up copies of all your Apache configuration files, in case one of the changes you make while experimenting renders the Web server inoperable.

Also, remember that configuration changes you make don't take effect until you restart Apache. If you've configured Apache to run as an inetd server, then you don't need to worry about restarting, since inetd will do that for you.

Download the reference card

As with other open-source projects, Apache users share a wealth of information on the Web. Possibly the single most useful piece of Apache-related information--apart from the code itself, of course--is a two-page guide created by Andrew Ford.

Called the Apache Quick Reference Card, it's a PDF file (also available in PostScript) generated from a database of Apache directives. There are a lot of directives, and Ford's card gives you a handy reference to them.

While this may not seem like a tip on how to run Apache, it will make your Apache configuration go much smoother because you will have the directives in an easy-to-access format.

One quick note--we found that the PDF page was a bit larger than the printable area of our printer (an HP LaserJet 8000 N). So we set the Acrobat reader to scale-to-fit and the pages printed just fine.

http://articles.techrepublic.com.com/5100-22-5076696.html

6

If you want to build quickly and creatively, you need to set up an environment that encourages and facilitates that process. If you don’t have the following basics down, your team will be constantly battling annoying issues instead of getting on with building. You’ll need:

  1. Good version control. I suggest Git.
  2. An easy-to-use source and changeset browser. We use Codebase.
  3. Solid server infrastructure. Why not build on Flexiscale, Grid-Service, Mosso or EC2 and let the big boys worry about uptime and server load?
  4. A ‘one-click’ deployment system. This means that deploying the code from your repository should take just one click. If it’s any more complex than that, there is potential for complications and downtime. Capistrano is brilliant if you’re using Rails.
  5. Printers, chalk boards and meeting space. People need the physical space to throw around ideas. We’ve painted an entire wall with blackboard paint so the team has room to sketch ideas.
  6. Coffee, water, music and healthy snacks.
7
I worked around the problem by editing
/usr/lib/gcc-lib///specs file
to remove the --as-needed and --noas-needed switches,
now everything works!

it's very strange that this problem occurs with the same exact version of gcc+binutils that don't have a problem on other platforms.
8

A HelloWorld Module

Apache:

1)build

gcc -fpic -DSHARED_MODULE -I/usr/include/apr-0 -I/usr/include/httpd -c  ./mod_helloworld.c

ld -Bshareable -o mod_helloworld.so mod_helloworld.o


2) install

cp ./mod_helloworld.so /usr/lib/httpd/modules/

chmod 755 /usr/lib/httpd/modules/mod_helloworld.so



vi  /etc/httpd/conf/httpd.conf


LoadModule helloworld_module modules/mod_helloworld.so
<Location /helloworld>
SetHandler helloworld
</Location>

then
apachectl restart

3) testing
http://localhost/helloworld
you will see :
this is a sample paged developed by xxxx after numerious struglling!!!

for apache2 in ubuntu

gcc -fpic -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -DSHARED_MODULE -I/usr/include/apache2 -I/usr/include/apr-1.0 -pthread -c mod_helloworld.c
ld -Bshareable -o mod_helloworld.so mod_helloworld.o
if you need to link additional library ld -Bshareable -o mod_helloworld.so mod_helloworld.o -L. -lmyutils

sudo cp ./mod_helloworld.so /usr/lib/apache2/modules
sudo chmod 644 /usr/lib/apache2/modules/mod_helloworld.so

then set up similar entries in /etc/apache2/
modules_available

like:
sudo cp ./status.load ./helloworld.load
sudo cp ./status.conf ./helloworld.conf

sudo vim ./helloworld.load
LoadModule helloworld_module /usr/lib/apache2/modules/mod_helloworld.so

sudo vim ./helloworld.conf
<IfModule mod_helloworld.c>
#
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Uncomment and change the ".example.com" to allow
# access from other hosts.
#
<Location /helloworld>
SetHandler helloworld
# Allow from .example.com
</Location>

</IfModule>


sudo ln -s ../mods-available/helloworld.conf ./helloworld.conf
sudo ln -s ../mods-available/helloworld.load ./helloworld.load



sudo /usr/sbin/apache2ctl stop
sudo /usr/sbin/apache2ctl start
9

As I said the second and third steps are troublesome only when not done before. Here is an implementation for those steps that I’ve written as a part of (yet unreleased) CGI library for C++. It implements functions that take the care of the first three steps and return to the user an STL map containing the form elements’ names in the key and their value in the map pair’s value. This functions allows to process forms in a similar way to processing forms in PHP using $_GET and $_POST.

Here is a simple example of processing a “get” form using the above getpost.h header file.

10

Apache JServ Protocol Version 1.1 (AJPv1.1)

Standard - September 9, 1998

describes the protocol used to communicate between a web server module
and the Apache JServ servlet engine over a TCP socket.

Introduction

The authentication scheme used for AJPv1.0 (used by Apache JServ 0.9.xx) was considered too simple and worked only on local environments. For this reason, while the request/response phase of the protocol were kept unchanged, authentication handshake was ported from higher versions of the protocol (proposed as a future extension) and implemented here for security reasons.

This will also provide more feedback to developers for newer revisions of the AJP protocol.

11
Cookies
Cookies are a method to store persistant data with the client. The system must be suppored by both the client (and enabled; there is much hype over a few relatively minor security considerations about cookies) and the web server (most do). Much information on exactly how this works with different browsers etc... can be found on the Internet. For the purposes of this brief document you only need to know the following:
Cookies are set with a header (before the Content) of the format:

Set-Cookie: name=value; expires=date; path=path; domain=domain; secure

Only the name=value bit is required and can contain anything other than semi-colons or whitespace. Expires is obvious, path the path on the server the cookie relates to (is provided to) i.e. /cgi-bin/ and domain is the domain the cookie relates to (is provided to) i.e. www.company.com or .company.com to provide it to www and www2.company.com).

Cookies are read via the HTTP_COOKIE environment variable and come in one long string of the format:

var1=value; var2=value; var3=value

If a cookie is set more than once (this can happen if, for example, the same cookie name is set for both .company.com and www.company.com - both are seen as seperate cookies by the browser but both are valid and provided to a request to www.company.com) it will appear twice (or however many times) in the list. By default (Firefox and IE with Apache) the cookie is valid for the FQDN of the webserver, for the directory the script that set it came from and for the duration of this session (usually until browser closes).

Add your comment: