The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Apache - with DSOs for PHP, FrontPage, and SSL under FreeBSD 4.0-S 6 May 2000
Need more help on this topic? Click here
This article has 1 comment
Show me similar articles
This is the fourth in a series of articles about installing a new server.   This article discusses how I installed Apache on a new server T was creating.
  1. Installing FreeBSD
  2. Getting cvsup
  3. make world
  4. installing Apache
Apache - the mega port
This article documents how I installed the Apache web server using Scot Hetzel's DSO tarball for Apache which is available at:

http://www.westbend.net/~hetzels/mod_apache.tgz

My main resource for this whole procedure is a message I found in the FreeBSD Mailing List Archives.

As root, I just grabbed the above tarball and untarred it in my home directory:

# cd home
# mkdir ports
# cd ports
# fetch http://www.westbend.net/~hetzels/mod_apache.tgz
# tar xvfz mod_apache.tgz
But first, a short rant...
One of the biggest headaches with Apache ports is you usually need a combination of modules which do not exist as a port.  Most people are either incapable or unwilling to do the work which is associated with creating a port.  All too often the work involved in reading the distributed and difficult to understand documentation is too huge of a task for many people.  I reject the hypothesis put forward by some geeks that software is simple.  No, it's not.

A port is simple.   That's why we have ports: to make it simple, easy, and convenient to install a port.  It is neither simple nor convenient to install software from sources.  If I had to select a single aspect of FreeBSD which stood out as it's strongest point, I think I'd chose the ports system.  In other systems, you have to track down the sources, read the install instructions, compile, make mistakes, re-read, ask questions, and then perhaps get it all running after a few days of trying.  That's not the case with ports: make install.  That's it.  You're running.  Easy?  You bet!

Port name and version name are needed
I'm installing under FreeBSD 4.0-STABLE.  The ports found in the above URL need slight modifications in order to work under 4.0-S.  In particular, if you try to build the port, you'll get this error:
[root@buff:/home/ports/apache13] # make
-: You need to define PORTNAME and PORTVERSION instead of PKGNAME.
(This port is too old for your bsd.port.mk.)
*** Error code 1

Stop.

:Luckily, this is easy to fix.  Just edit each Makefile and make a simple change.   Here is a before and after for apache13/Makefile:

Before After
DISTNAME= apache_${VERSION_APACHE}
#PKGNAME= apache-${VERSION_APACHE}
DISTNAME= apache_${VERSION_APACHE}
#PKGNAME= apache-${VERSION_APACHE}
PORTNAME= apache
PORTVERSION= ${VERSION_APACHE}

You should make similar changes for each Makefile.  You'll find one in each directory from the tarball.  I changed the following files:

  • apache13/Makefile
  • mod_ssl/Makefile
  • mod_frontpage/Makefile
  • mod_php3/Makefile

I have a patch file which will make these changes for you.  To apply this patch, copy it to the same directory as the main tarball (which was /home/ports in my example) and issue the following command:

patch < mod_apache.diff
Installing Apache
The first step is to build Apache.  Then we will deal with the othe modules.  I made another change to the Makefile.  I prefer to run Apache with a user/group of www/www.  I added the user and group first.  Here's what I added using vipw:
www:*:99:99::0:0:apache Daemon:/nonexistent:/sbin/nologin

Then I added this to /etc/group:

www:*:99:

After making the above changes, I was ready to modify apache13/Makefile.  I located the following lines

# cd apache13
# make all install

I selected both the tuning and des cript thingy.

The first time I tried this, I encountered this error:

No descrypt library installed.
*** Error code 1

Hmmm.  I thought about this for a bit.  I had just installed FreeBSD from CD.   I concluded the crypto stuff was not installed as part of that process (possibly due to export restrictions).  So I did what I planned to do anyway: upgrade to stable.  That process is documented elsewhere.

Starting Apache - you must fix this apache.conf error
Here's what I encountered when I tried to start Apache:
# /usr/local/sbin/apachectl start
Syntax error on line 1342 of /usr/local/etc/apache/apache.conf:
2 missing </ifmodule< directives at end-of-file
/usr/local/sbin/apachectl start: httpd could not be started

The error is easily fixed, but it wasn't so easy to find.  It took me twenty minutes of trial and error to locate it.  Edit /usr/local/etc/apache/apache.conf and locate the following (possibly around line 465):

<IfModule mod_php4.c>
  DirectoryIndex index.html index.php3 index.php4
<IfModule>

There is a missing / on the last line.  Each <IfModule> needs a </IfModule>.  Just modify the second <IfModule> to be </IfModule>.

Then I started Apache:

# /usr/local/sbin/apachectl start
/usr/local/sbin/apachectl start: httpd started

WARNING: Note that you should fix this error regardless.  It will not show up after you install php3.  The problem you will encounter will be a DirectoryIndex problem.  Namely, index.php3 will not be picked up by Apache.  Instead you will see a directory listing when you browse to a directory which contains an index.php3.

Adding php3
Following the suggestions in the message I found, I then did this
# cd mod_php3
# make all install    

Then I stopped Apache and then started it.

# /usr/local/sbin/apachectl stop
/usr/local/sbin/apachectl stop: httpd stopped
# /usr/local/sbin/apachectl start
Syntax error on line 721 of /usr/local/etc/apache/apache.conf:
Invalid command '</IfModule', perhaps mis-spelled or defined by
a module not included in the server configuration
/usr/local/sbin/apachectl start: httpd could not be started

Again, this problem is easily solved.  Note, your line number may differ.   Line 721 looks like this:

</IfModule mod_php3.c>

And it should look like this:

</IfModule>
Testing php3
I created the following file /usr/local/www/data/test.php3:
<html>
<body>
Hi <i>mom</i>!
<?
echo "<br>hi son";
?>
</body>
<html>

Then I broswed to this page on my server: http://myserver.org/test.php3, where I saw this:

Hi mom!
hi son

Good.  That's php3 going!

Adding ssl
Again, following the suggestions in the message I found, I then did this
# cd mod_ssl
# make all install    

Then I stopped Apache and then started it.  That's where I stopped with SSL.   I don't actually need SSL, but if anyone wishes to document how to get it running, I'll add it here.  Thanks.

Adding FrontPage
Again, following the suggestions in the message I found, I then did this
# cd mod_frontpage
# make all install    

Then I stopped Apache and then started it.  That's where I stopped with SSL.   I don't actually need SSL, but if anyone wishes to document how to get it running, I'll add it here.  Thanks.

During the install process, you will be asked various questions.  Before you answer any questions, make sure the appropriate values are set in your /usr/local/etc/apache/apache.conf.  My suggested values are in [square brackets].

  • User [www]
  • Group [www]
  • ServerName [server.yourdomain.org]  <== this occurs in various places in the file
  • ServerAdmin [webmaster@yourdomain.org] <== this occurs in various places in the file

For an example of how to answer these questions, see my examples.   Although they may be some what dated, they might prove useful.

Other things to do
You may want to add virtual hosts.

And then install Front Page extensions for those virtual hosts.

Problems
I had an issue whereby my hostname didn't match my IP address.  This meant that browing to the website caused a problem.  For example, the graphics did not appears correctly.  So I went through apache.conf and changed the hostsnames (say from host.mydomain.org to host.int.mydomain.org).  But that wasn't enough to fix the problem.  I also had to modify /usr/local/www/data/index.html and change the host names in there too.  That fixed the problem.

Need more help on this topic? Click here
This article has 1 comment
Show me similar articles