Configure Apache in FreeBSD

Sep 20, 2012 9:05 PM

  _______  _________   _______  __________ ____ ____  __________
 /   O   \|    _o___) /   O   \/   /_____//   /_\   \/   /_____/
/___/%\___\___|%%%%%'/___/%\___\___\%%%%%'\___\%/___/\___\%%%%%'
`BB'   `BB'`B'       `BB'   `BB'`BBBBBBBB' `BB' `BB'  `BBBBBBBB'

I think you already know freebsd has ports facility that so much eased sysadmin in installation software. Including apache, php and mysql enable you to install through ports. If you didn't install apache before, or it's the first time apache installation, you can go to /usr/ports/www/apache22 directory. You will build apache from here.


# cd /usr/ports/www/apache22
# make install clean

If you meet error messages like.. "Couldn't fetch it - please try to retrieve this",  then don't be confused and keep strong. You can do portsnap to fetch ports again. For checking installed apache package, it could be use pkg_info.


# pkg_info | grep -i apache                                               
app2-mod_dnssd-0.6_8 An Apache module that provides DNS-SD capabilities   
apache-2.2.21        Version 2.2.x of Apache web server with prefork MPM.  
apache22-2.2.22_8    Version 2.2.x of Apache web server with prefork MPM.  
apr-ipv6-devrandom-gdbm-db43-1.4.5.1.3.12_1 Apache Portablity Library      

Check apache configuration file (/usr/local/etc/apache22/httpd.conf) and make change for some entry like server root, document root, server name, server admin, and etc as shown bellow:

ServerRoot "/usr/local"                                                    
ServerAdmin war49@myexample.com                                           
ServerName www.myexample.com                                               

DocumentRoot "/usr/local/www/apache22/data"                               

ServerRoot is a root directory for of apache, when binary program are in bin (/usr/local/bin) services are in sbin (/usr/local/sbin). ServerAdmin is entry for your email. ServerName is your domain. And DocumentRoot is directory where website files are stored. Whatever configuration changes that you make, then we must execute the http service. But, to make sure that modification is correct, you must check with `config test`.


# /usr/local/etc/rc.d/apache22 configtest                                  
-or-                                                                       
# service apache22 configtest                                              

Apache can be run with two different way.


# /usr/local/etc/rc.d/apache22 start                                       
-or-                                                                       
# service apache22 start   

                                               


Test with lynx or links,
# lynx localhost
>>>>>>>CIAAOO<<<<<<<<

Article list :