FAMP (FreeBsd Apache MySql Apache)

From The Wiki Guide

Jump to: navigation, search

Contents

Introduction

This guide will enable you to setup a basic FAMP installation, similiar to the standard LAMP configurations found on modern Web Servers. You will be able to run PHP based forums, Wiki's,PHP Based Gallerys, and Programs which require a MySql backend, with this basic configuration. This guide is in no way a definitive guide, it is just a get you up and running type of guide. You should be aware of any program or port you install, and be familiar with its bugs, vulnerabilities, dependencies, etc.

FreeBSD Install

  1. Install FreeBSD off the CD..
    • Choose All binaries, and X win system
    • Choose to install ports
  2. Add username to Wheel GRP:
    • ee /etc/group
    • then next to "wheel:*root" type ",username"
  3. Compile CVSup
    • cd /usr/ports/net/cvsup
    • then "make install" and "rehash"and"sync"
  4. Copy ports-supfile
    • cp /usr/share/examples/cvsup/ports-supfile /usr/local/bin/
    • ee /usr/local/bin/ports-supfile
    • (Add the following)
"*default base=/usr"
"*default prefix=/usr"
"*default release=cvs"
"*default delete"
"*default use-rel-suffix"
"*default tag=."
"*default compress"
"src-all"
"ports-all"
"doc-all"
  • Save and exit
  • Run "cvsup -g -L 2 ports-supfile"
  • To get locate working:
    • /usr/libexec/locate.updatedb
  • Add a default route/gateway
    • route add default x.x.x.x
  • Add a DNS server
    • echo "nameserver x.x.x.x" >/etc/resolv.conf
  • Optional KDE Install
  1. pkg_add -r kde
  2. echo "exec startkde" ~/.xinitrc
  3. Type "startx" to get into KDE
  • Port Install Procedure:
  1. locate package (will list the directory and available packages)
  2. cd /usr/ports/portdirectory
  3. make install (will go through the 3 step install process)
  4. pkg_add -r package (no compiling, faster install)
  • After every install:
  1. rehash (updates the hash tables to add the newly installed port directory)
  2. sync (writes any files in the buffer to the system, updates inodes)

Apache Install

  1. locate apache2
  2. cd /usr/ports/www/apache2x
  3. make install
  • Defaults:
    • DataLocation- /usr/local/www/data-dist
    • Httpd.conf- /usr/local/etc/apache2/
  • Tip: Make a symbolic link to the Web Dir, so its easier to access the web shared folder.
    • ex. ln -s /usr/local/etc/apache2x /webdir
  • Edit your Httpd.conf accordingly and test apache.
  • Edit Hosts file
    • ee /etc/hosts (change localhost to name of computer)
  • Edit rc.conf: ee /etc/rc.conf
    • ADD apache_enable="YES"
  • Quick and Dirty
    1. Place your email next to ServerAdmin
    2. Place the ip of your machine next to ServerName(x.x.x.x:80)
    3. Start Apache
  • Commands:
    • apachectl start
    • apachectl stop
    • apachectl restart

MySql Install

  • locate mysql (get an idea of where the ports are)
  • Client:
    1. cd /usr/ports/databases/mysql3x-client
    2. make install
    3. rehash
    4. sync
  • Server:
    1. cd /usr/ports/databases/mysql3x-server
    2. make install
    3. rehash
    4. sync
  • Configure Startup Script:
    1. ee /usr/local/etc/rc.d/mysql-server.sh
    2. FIND ${mysql_enable= and set it to ${mysql_enable="YES"}
    3. Run the script /usr/local/etc/rc.d/mysql-server.sh
    • Since the script is placed in rc.d, it will start Mysql on boot
  • Check that MySql is running "ps aux | grep mysql"
  • Location of the Database files: /var/db/mysql
  • Changing the root password: mysqladmin -u root password newpassword
    • After that when logging in use mysqladmin -u root -p (it will prompt for pass which is more secure)
  • Creating a DB
    1. login to mysql mysql -u root -p
    2. mysql> create database testdb;
  • Creating a User, and giving them perms:
    1. login to mysql mysql -u root -p
    2. mysql> grant usage on testdb.* to pingu@localhost; (creates user pingu, who can use testdb database)
    3. mysql> grant select, insert,delete on testdb.* to pingu@localhost;(Lets pingu select insert and delete)
  • There are tons and tons of more options, this is just a basic, Q&D....

PHP Install

  • Install the Main PHP Port
    1. cd /usr/ports/lang/php4/
    2. make install
    3. rehash
    4. sync
  • Install PHP Extensions
    1. /usr/ports/lang/php4-extensions
    2. make install
    3. rehash
    4. sync

If all went well you should now have a Full FAMP installation, and a fully functional Web Server, CONGRATULATIONS!


Tutorial Author: RaMzi
RBPC@bellsouth.net

Special Thanks:
Gerbil & bWattel(gave me the FreeBSD fever,and tons of help)
Ookami (L337 Linux Skillz,kick ass forum, and Wiki)