Ultimo FreeBSD
Author: jason
Date: 2003-11-25
Category: Technical

Now that you've installed FreeBSD, wouldn't you like to do something with it? Like host a web or ftp server? Use a cool web GUI to manage your machine?

See your machine's pretty system resources?

Well, go download:
apache
php
proftpd
webmin
phpSysInfo

I'll show you how to install and configure them, promise!

Put them in the /home directory... I normally use WinSCP2 over SSH to place move files around. Then su to your heart's content!

>tar -zxvf httpd-2.0.48.tar.gz
>tar -zxvf php-4.3.4.tar.gz
>tar -zxvf proftpd-1.2.9.tar.gz
>tar -zxvf webmin-1.121.tar.gz
>tar -phpSysInfo-2.1.tar.gz

Starting with apache:
>cd httpd-2.0.48
>./configure --with-apxs2 --enable-so
>make
>make install

The default directories are:
htdocs /usr/local/apache2/htdocs
cgi-bin /usr/local/apache2/cgi-bin
httpd.conf /usr/local/apache2/conf
httpd /usr/local/apache2/bin
apxs2 /usr/local/apache2/bin/apxs

Here is my apache.sh start/stop file:
Code

#!/bin/sh

case "$1" in

start)
/bin/mkdir -p /usr/local/var/apache
if [ -x /usr/local/apache2/bin/httpd ]; then
/usr/local/apache2/bin/httpd
echo -n ' apache'
fi
;;

stop)
killall httpd
;;
*)
echo "$0 start | stop"
;;

esac


To use the start up file on system boot up you'll need to make a rc.d directory
>mkdir /usr/local/etc/rc.d

After typing out the apache.sh file place it in rc.d, and set the permissions
>cp apache.sh /usr/local/etc/rc.d
>chmod 755 /usr/local/etc/rc.d/apache.sh

Now that wasn't so hard, was it?

Onto php:
>cd ../php-4.3.4
>./configure --with-tsrm-pth --with-apxs2=/usr/local/apache2/bin/apxs
>make
>make install
>cp php.ini-dist /usr/local/etc

The default directories are:
php /usr/local/bin
lib /usr/local/lib/php
includes /usr/local/include/php
php.ini /usr/local/etc

Now check and make sure php is referenced in apache's config file
>ee /usr/local/apache2/conf/httpd.conf

Under Dynamic Shared Object (DSO) Support (line 221) look for:
LoadModule php4_module modules/libphp4.so

If you do not have a DSO section then apache was not configured with so support

Move down to line 394: DirectoryIndex index.html index.var.html add index.php

Scroll down to line 839... Under AddType add the following line:
AddType application/x-httpd-php .php

This sets the mime type for apache to execute .php files. Yes, there is a space between x-httpd-php and .php
Then hit Escape, choose a) Leave editor - Save Changes

Remove the default apache fluff files
>cd /usr/local/apache2/htdocs/
>rm *

Place your neato system resource page as the first/default web page: >cd /home/phpSysInfo-2.1
>cp -R * /usr/local/apache2/htdocs

Now start up apache!
>/usr/local/etc/rc.d/apache.sh start

You'll probably see a message about apache not knowing the fully qualified domain name. You can check to make sure apache is running by typing ps -aux and looking for httpd. If you want to avoid the domain name stuff then update your /etc/hosts file with the appropriate lingo and ip.

Visit your IP to see your pretty system resources page!! http://10.10.10.10 (just an example... don't actually go there...) If you see php gooblygook, the php isn't configured in apache correctly. Try again!

Onto webmin:
>cp -R /home/webmin-1.121 /usr/local/webmin
>cd /usr/local/webmin
>./setup.sh

Choose the defaults, and enter your desired username and password. Change the default port, if you like. Remember to let webmin start at boot up.

The default directories:
/usr/local/webmin (because that's where you put it!)
/etc/webmin
/etc/webmin/webmin
/var/webmin

You need to move webmin, because that's where it runs out of... I think... It stays wherever you put it...

Now visit your ip with a port of 10000, or whatever you choose: http://10.10.10.10:10000 Login, and configure to your heart's content!!

Almost done!! Aren't you excited?

Onto proftpd:
>cd /home/proftpd-1.2.9
>./configure
>make
>make install
>cp sample-configurations/basic.conf /usr/local/etc/proftpd.conf

The default directories are:
proftpd.pid /usr/local/var
proftpd.scoreboard /usr/local/var/proftpd
proftpd /usr/local/sbin
proftpd.conf /usr/local/etc

Change the defaults of proftpd.conf... I've given some of my config settings

>ee /usr/local/etc/proftpd.conf
Code

Add some greetings after login
# Reference http:/ /www.proftpd.org/docs/directives/linked/config_ref_DisplayFirstChdir.html
# for some neat stuff with %
AccessGrantMsg "Hello %u, welcome to jasonthomasfrance.org"
AccessDenyMsg "Please try again, or go away"

# Speed up logging in
IdentLookups off
UseReverseDNS off

# Cause every FTP user to be "jailed" (chrooted) into their home
# directory, except those in the wheel group
DefaultRoot /home !wheel


Here is a start/stop script for proftpd:
Code

#!/bin/sh

case "$1" in

start)
/bin/mkdir -p /usr/local/var/proftpd
if [ -x /usr/local/sbin/proftpd ]; then
/usr/local/sbin/proftpd
echo -n ' proftpd'
fi
;;

stop)
killall proftpd
;;
*)
echo "$0 start | stop"
;;

esac


After making the proftpd.sh file place it in rc.d, and set the permissions
>cp proftpd.sh /usr/local/etc/rc.d
>chmod 755 /usr/local/etc/rc.d/proftpd.sh

Now start it up!
>/usr/local/etc/rc.d/proftpd.sh start

If you see some errors then you need to check your configuration...

As people login you'll see some 'ftp' module not loaded messages pop up onto the screen. This is the pam telling you that ftp isn't quite all the way configured It will work... but... You might want to modify the pam:
>ee /etc/pam.conf

Look for the ftp section, make it look like this:
Code

# Same requirement for ftpd as login
ftp auth sufficient pam_skey.so
ftp auth sufficient pam_opie.so no_fake_prompts
#ftpd auth requisite pam_opieaccess.so
ftp auth requisite pam_cleartext_pass_ok.so
#ftpd auth sufficient pam_kerberosIV.so try_first_pass
#ftpd auth sufficient pam_krb5.so try_first_pass <
ftp auth required pam_unix.so try_first_pass <
ftp account required pam_unix.so try_first_pass
ftp session required pam_permit.so


Then hit Escape, Choose a) leave editor, save changes.

Now pam should leave proftpd alone...

And we're done!! You've got a functional web and ftp server with a pretty system resource page and an online server manager...

Now you're definitely a BSD geek!!

***************
written by jasonthomasfrance
date 25 Nov 2003
systems FreeBSD 4.8
*********



jason @ jasonthomasfrance.com - www.masterstationlog.com - copyright 2009