Posted 07.03.2005 | Updated 26.05.2006 | Contributed by Andy Mallett & Brad Robinson
Any self-respecting Unix box needs to be running useful apps. These applications are almost must-haves for most BSD Servers.
Sometimes called a L.A.M.P. Server (Linux, Apache, Mysql, PHP/PERL), I find the name a tad inappropriate as we're running FreeBSD (BAMP Server?).
In addition I'm including other bits too, like IMAP. So let's just call it the instructions for installing a VERY BIG SERVER.
The following shows how to set up Imap, Mysql, Apache, Php, & Mod_perl as a group of apps in a specific sequence.
|
|
Note PERL itself is already installed with the current FreeBSD distributions (5.4).
Don't be put off by the seemingly enormous size of this page. Take each section at a time and double check all your settings as you go. It's not as complicated as it looks.
NOTE: It is critical that you install the packages in the following order, otherwise you will have errors in your server tree config..
Packages and versions useed..
- imap-2000c.tar.Z [1.8M]
- mysql-4.0.18.tar.gz [12.8M]
- apache_1.3.17.tar.gz [1.8M]
- php-4.3.4.tar.gz [4.4M]
- mod_perl-1.27.tar.gz [363K]
|
|
Making Directories
Create the following directories..
mkdir /src (or /usr/local/src if you like typing a lot..)
mkdir /usr/local/apache
mkdir /usr/local/mysql
Copy all of the above tarballs into the /src directory
IMAP
I recommend always installing IMAP, so that system messages can be pulled over from another workstation. See Installing IMAP for details.
Mysql Server Setup
Ah, MySQL..a specialist subject in its own right really. Add to this the fact that the "current" version of MySQL seems to change on an almost hourly basis and it can be a bit tricky keeping up. The latest of my documented installs of MySQL is MySQL 4.0.18. Install it.
Pre-Configure Apache
Again, different versions are creeping upon us. Note that these instructions show how to install and configure Apache 1.3.17 which at the time of writing, is still recommmended.
Move into the /src directory and unpack the apache tarball:
tar -zxvf apache_1.3.17.tar.gz
Move into the newly created apache directory:
cd apache_1.3.17
Next you need to build a configure script. This must be done as root:
vi apachescript
Inside this first Apache script type:
./configure --prefix=/usr/local/apache
Once you have saved and exited the script, run it:
sh apachescript
PHP4 Setup
Move into the /src diectory and unpack the php tarball:
tar -zxvf php-4.3.4.tar.gz
Move into the newly created php directory:
cd php-4.3.4
Make the following links:
ln -s /src/imap-2000c/c-client /src/imap-2000c/c-client/lib
ln -s /src/imap-2000c/c-client /src/imap-2000c/c-client/include
Next you need to build a configure script. This must be done as root:
vi php4script
Inside the PHP4 script type:
#!/bin/sh
#PHP4 Script
./configure --with-apache=/src/apache_1.3.17 \
--with-imap=/src/imap-2000c/c-client \
--with-mysql \
--enable-track-vars
Once you have rechecked the script for accuracy, save and exit the script and run it:
sh php4script
After this script runs do the following:
make
make install
Mod_Perl Setup
PERL is already an intrinsic part of the modern FreeBSD. However it is necessary to install mod_perl. At this point it is recommended to undertake the mod_perl installation
Apache Server Setup
Move into the /src/apache_1.3.17 diectory:
cd /src/apache_1.3.17
Next you need to build a configure script. This must be done as root:
vi apachescript2
Inside the second Apache script type:
#!/bin/sh
#Apache Configure Script
./configure --prefix=/usr/local/apache \
--activate-module=src/modules/php4/libphp4.a \
--enable-shared=php4 \
--activate-module=src/modules/perl/libperl.a
Important! Note the paths to src quoted above are not preceeded by a /. The above script will be created inside /src/apache_1.3.17 and refers the the src directory within this directory.
Once you have checked, saved and exited the script, run it:
sh apachescript2
After this script runs do the following:
make
make install
Apache Server Configuration
Move into the /usr/local/apache/conf directory:
cd /usr/local/apache/conf
Make a backup copy of httpd.conf and then open up the httpd.conf file with vi:
cp httpd.conf httpd.conf.bak
vi httpd.conf
Find the Directory Index directive (roughly line 391) and add the following entries:
index.htm index.php index.php3
The line should now read:
DirectoryIndex index.html index.htm index.php index.php3
Find the AddType (php 4.x) section (roughly lines 767 & 768) and un-hash both sections so that they read:
Add Type application/x-httpd-php .php
Add Type application/x-httpd-php-source .phps
Add .php3 to the 1st line so that it reads:
AddType application /x-httpd-php .php .php3
Save and exit httpd.conf
Make the following link:
ln -s /usr/local/apache/bin/apachectl /usr/local/sbin/apachectl
To start the apache server run:
apachectl start
To stop the apache server run:
apachectl stop
To restart the apache server run:
apachectl restart
To make Apache run from boot, create an rc.local file and add the following line..
vi /etc/rc.local
/usr/local/apache/bin/apachectl start
See Services, Automating for more info on this method.
To Test Apache Server
First make yourself a quick test web page named index.html. Put it in your document root (htdocs folder). Go to a web browser and type the following address:
http://YOUR-IP/index.html
(you may also use your hostname instead of IP address)
To Test PHP Support
Move into the /usr/local/apache/htdocs directory:
cd /usr/local/apache/htdocs
Create a php test file called phptest.php:
vi phptest.php
Type the following:
<?
phpinfo();
?>
Save and exit the file. Go to a browser on another machine and test you php support with this address:
http://YOUR-IP/phptest.php
You will see a web page with information about your build.
To Test Perl Support
From the command line as root type:
telnet 127.0.0.1 80 (and press ENTER)
HEAD / HTTP/1.0 (and press ENTER twice)
You should get some information about you perl build. Date built, server, last modified date:
HTTP/1.1 200 OK
Date: Sun, 06 Mar 2005 10:49:39 GMT
Server: Apache/1.3.17 (Unix) mod_perl/1.27 PHP/4.3.4
Content-Location: index.html.en
Vary: negotiate,accept-language,accept-charset
TCN: choice
Last-Modified: Fri, 19 Jan 2001 19:39:47 GMT
ETag: "23309-51e-3a689803;422addce"
Accept-Ranges: bytes
Content-Length: 1310
Connection: close
Content-Type: text/html
Content-Language: en
Expires: Sun, 06 Mar 2005 10:49:39 GMT
And that's about all there is to it. If you got it right first time around, well done! If not, don't give up - go back and check your coding.
- A&B.
|
|