PHP with Apache MPM Worker
I didn't know if this is going to work or not, but I wanted at least to try Apache MPM Worker with PHP. I started with a minimal Centos5.4 installation, installed gcc and the rest of the family, download apache2.2.16 and php-5.2.14, started the compilation and building.
Installing GCC and the rest of the family...
# yum install gcc.i386 automake17.noarch libtool.i386 m4.i386 autoconf.noarch zlib-devel.i386 openssl-devel.i386
Download and build apache2.2.16
# cd /usr/src && wget http://www.alliedquotes.com/mirrors/apache/httpd/httpd-2.2.16.tar.gz && tar xzvf httpd-2.2.16.tar.gz && cd httpd-2.2.16
# ./configure --enable-layout=CustomApache --with-mpm=worker --enable-modules='ssl deflate' --enable-mods-shared='headers rewrite' && make && make install
This is my config.layout...
<layout CustomApache>
prefix:
exec_prefix: ${prefix}/usr
bindir: ${exec_prefix}/bin
sbindir: ${exec_prefix}/sbin
libdir: ${exec_prefix}/lib/apache2/lib
libexecdir: ${exec_prefix}/lib/apache2/modules
mandir: ${exec_prefix}/share/man
sysconfdir: ${prefix}/etc/apache2
datadir: ${exec_prefix}/share/apache2
iconsdir: ${datadir}/icons
htdocsdir: ${prefix}/var/www
manualdir: ${htdocsdir}/manual
cgidir: ${prefix}/var/www/cgi-bin
includedir: ${exec_prefix}/include/apache2
localstatedir: ${prefix}/var/run
runtimedir: ${prefix}/var/run
logfiledir: ${prefix}/var/log/apache2
proxycachedir: ${prefix}/var/cache/apache2/proxy
infodir: ${exec_prefix}/share/info
installbuilddir: ${prefix}/etc/apache2/build
errordir: ${datadir}/error
</layout>
Configuring apache...
(I like to write my apache config file from scratch, so I started with a very minimal config file, minimal just to get apache up and running)
# mv /etc/apache2/httpd.conf /etc/apache2/httpd.conf.orig && vi /etc/apache2/httpd.conf
This is my httpd.conf
Listen 80
LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
user apache
DocumentRoot "/var/www"
ErrorLog "/var/log/apache2/error_log"
Starting apache...
# apachectl -k start
Issuing `ps xa | grep httpd` will tell you if apache is running or not.
Now it was time to compile php, I installed dev packages before compiling php...
# yum install libxml2.i386 libxml2-devel.i386 bzip2.i386 bzip2-devel.i386 bzip2-libs.i386 curl-devel.i386 curl.i386 gettext.i386 gettext-devel.i386 libc-client-devel.i386 gd-devel.i386 libmcrypt.i386 libmcrypt-devel.i386 mysql.i386 mysql-server.i386 mysql-bench.i386 mysql-devel.i386 readline-devel.i386 libtool.i386 libtool-ltdl.i386 libtool-ltdl-devel.i386
Download and build php-5.2.14...
# cd /usr/src && wget wget http://www.php.net/get/php-5.2.14.tar.gz/from/de.php.net/mirror && tar xzvf php-5.2.14.tar.gz && cd php-5.2.14
# ./configure --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib/php/modules --datadir=/usr/share/php --sysconfdir=/etc/php --with-apxs2=/usr/sbin/apxs --with-openssl --with-zlib --with-bz2 --with-curl --with-gd --with-gettext --with-imap --enable-mbstring --with-mcrypt --with-mysql --with-readline --enable-sockets --enable-soap --with-kerberos --with-imap-ssl && make && make install
Now, edit httpd.conf and add
# vi /etc/apache2/httpd.conf
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
<ifmodule dir_module>
DirectoryIndex index.php index.html
</ifmodule>
<ifmodule mime_module>
AddType application/x-httpd-php .php
</ifmodule>
And restart apache
# apachectl -k restart
Quick Note: Searching FreeBSD ports
If you already have the Ports Collection installed on your machine, you may search by changing to the /usr/ports directory and performing ``make search name=string``
# cd /usr/ports
# make search name=portname
BIND9 on FreeBSD
The Domain Name System, or DNS, is one of the Internet's fundamental building blocks. It is the global, hierarchical, and distributed host information database that's responsible for translating names into addresses and vice versa, routing mail to its proper destination, and many other services.
For this article I used a fresh installation from 8.0-RELEASE-i386-bootonly, enabled ssh, and installed bash. First thing I fetched the latest release for the ports, installed portupgrade and updated the system...
# portsnap fetch extract
# cd /usr/ports/ports-mgmt/portupgrade && make install clean
# portupgrade -a
Installation...
# cd /usr/ports/dns/bind97/ && make install clean
You are free to choose which options are to be compiled with bind, but make sure you choose REPLACE_BASE. It's always a good idea to run bind in a chroot-ed environment
# mkdir -p /var/chroot/named/etc/namedb /var/chroot/named/dev /var/chroot/named/var/run
# chown -R bind:bind /var/chroot/named/
# chmod 755 /var/chroot/named/
# chmod 555 /var/chroot/named/dev
# ln -s /etc/localtime /var/chroot/named/etc/localtime
# mknod /var/chroot/named/dev/zero c 2 12
# ln -s /dev/random /var/chroot/named/dev/random
# mknod /var/chroot/named/dev/null c 2 2
# chmod 666 /var/chroot/named/dev/*
# mv /etc/namedb /etc/old.namedb
# ln -s /var/chroot/named/etc/namedb /etc/namedb
Configuration...
# dig > /etc/namedb/named.root
# rndc-confgen -a -c /etc/namedb/rndc.conf -k rndc-key -b 256
# vi /etc/namedb/named.conf
controls { inet 127.0.0.1 port 953 allow { localhost; } keys { rndc-key; }; };
include "/etc/namedb/rndc.conf";
acl "trusted" { 127.0.0.1; 192.168.0.0/16; };
options {
directory "/etc/namedb";
pid-file "/var/run/named.pid";
dump-file "/var/dump/named_dump.db";
statistics-file "/var/stats/named.stats";allow-transfer { 127.0.0.1; 192.168.56.3; };
listen-on { 127.0.0.1; 192.168.56.2; };auth-nxdomain yes;
};view "internal" {
match-clients { "trusted"; };
recursion yes;zone "." { type hint; file "named.root"; };
zone "localhost" { type master; file "master/localhost-forward.db"; };
zone "127.in-addr.arpa" { type master; file "master/localhost-reverse.db"; };
};view "external" {
match-clients { any; };
recursion no;
};logging {
channel systemlog {
file "/var/log/named.log";
severity debug;
print-time yes;
};channel audit_log {
file "/var/log/security.log";
severity debug;
print-time yes;
};channel xfer_log {
file "/var/log/xfer.log";
severity debug;
print-time yes;
};category default { systemlog; };
category security { audit_log; systemlog; };
category config { systemlog; };
category xfer-in { xfer_log; };
category xfer-out { xfer_log; };
category notify { audit_log; };
category update { audit_log; };
category queries { audit_log; };
category lame-servers { audit_log; };
};
After that, create /etc/namedb/master/localhost-forward.db and /etc/namedb/master/localhost-reverse.db
# vi /etc/namedb/master/localhost-forward.db
$TTL 3h
localhost. SOA localhost. nobody.localhost. 42 1d 12h 1w 3hNS localhost.
A 127.0.0.1
# vi /etc/namedb/master/localhost-reverse.db
$TTL 3h
@ SOA localhost. nobody.localhost. 42 1d 12h 1w 3hNS localhost.
1.0.0 A localhost.
And start named...
# echo named_enable="YES" >> /etc/rc.conf
# /etc/rc.d/named start
Following up is creating slave name server, creating a zone and syncing the master ns with the slave name server.
Upgrading FreeBSD ports using portsnap and portupgrade
Portsnap is an alternative system for distributing the Ports Collection. Please refer to Using Portsnap for a detailed description of all Portsnap features.
First download a compressed snapshot of the Ports:
If it's the first time running portsnap...
# portsnap fetch extract
If you already have a populated /usr/ports and you are just updating...
# portsnap fetch update
A quick useful tip to check the outdated ports installed locally and their updates...
# portversion -vL=
To upgrade all of the outdated ports...
# portupgrade -a
To upgrade one or more ports...
# portupgrade bash bzip2 conky
Aggregating network interfaces (Debian)
Link aggregation or IEEE 802.1AX-2008 is a computer networking term which describes using multiple network cables/ports in parallel to increase the link speed beyond the limits of any one single cable or port, and to increase the redundancy for higher availability.
Other terms for link aggregation include Ethernet bonding, NIC teaming, Trunking, port channel, link bundling, EtherChannel, Multi-link trunking (MLT), NIC bonding, network bonding, and Network Fault Tolerance (NFT).
First install ifenslave:
# apt-get install ifenslave
Then edit /etc/modprobe.d/arch/i386 and append to it:
alias bond0 bonding
options bond0 mode=balance-alb miimon=100
Then edit /etc/network/interfaces and configure the new interface
auto bond0
iface bond0 inet static
address 10.0.0.100
netmask 255.0.0.0
network 10.0.0.0
gateway 10.0.0.1
up /sbin/ifenslave bond0 eth0 eth1
Then restart the networking
# /etc/init.d/networking restart