Initial FreeBSD installation
Download OS from the FreeBSD website, etc.
Use sysinstall to get running the initial desired FreeBSD configuration.Update ports collection from the FreeBSD site:
- For the first time:
portsnap fetch portsnap extract
- Afterwards, instead of two two above:
portsnap update
Install and configure text editor ne:
cd /usr/ports/editors/ne make install clean
Start ne, press F1(menu), chose /Pfers/Save Def Prefs - it creates a file~/.ne/.default#ap.
Edit file.default#ap: add lineEscapeTime 250, copy file to other users'~/.ne/directory.
From now you can use ne instead of vi editor.
So use ne to setEDITOR=neand shell aliases for users (edit~/.profilefiles), so ne becomes your default editor on FreeBSD system:EDITOR=ne; export EDITOR PAGER=less; export PAGER
If using PuTTY SSH shell to access the system - set backspace Key toCtrl-H.
Change your shell to bash:
Simply run thechsh(Change Shell) program, and change theShell:line:Shell: /usr/local/bin/bash
Beautify/colorize directory listings:
Add following alias lines or the~/.profilefile:alias ls='ls -G' alias ll='ls -lG' alias la='ls -lGAFo'
This will add colors based on file type when viewing directory listing using commandsla,llandla.Install text-based mail reader mutt:
I couldn't do it though ports collection usingmakeutility, neithermuttnormutt-lite.
Pull and install pre-compiled package from the FreeBSD repository website:pkg_add -r mutt-lite
After initial try of the mutt, set its split-window option by editing file/usr/local/etc/Muttrcand addingpager_index_lines=10there.Configure ntpd Network Time Protocol (NTP) daemon:
Select public time servers from ntp.org website.
Create/etc/ntp.conffile and add a list of the few time servers there that is close to you location, for example:server 0.north-america.pool.ntp.org server 1.north-america.pool.ntp.org server 2.north-america.pool.ntp.org server 3.north-america.pool.ntp.org
You can also set other systems on your network to use your FreeBSD Server for time synchronization. To make this more secure, add the following line to the/etc/ntp.conffile:restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
(change IPs as required). This will allow access to the ntpd daemon only from the computers on your local subnet.
Add ntpd daemon to the/etc/rc.confso it starts starts at boot time:ntpd_enable="YES"
Type commandntpdto start daemon manually with default parameters.Install Apache (apache22) port:
This and few other steps below are described in details in other documentation - I may add some additional details here later.Install MySQL port:
That ismysql(XX)-serverport.
Afterwards don't forget to change/set MySQL' admin password:mysqladmin -u root password XXXXXXX
Install php5 port:
cd /usr/ports/lang/php(5?) make isntall clean
Ensure Apache is selected in the UI.
Assign aphp.inifile:cp /usr/local/etc/php.ini-recommended /usr/local/etc/php.ini
You can see differences betweenphp.ini-distandphp.ini-recommendedversions usingdiffutility:diff /usr/local/etc/php.ini-dist /usr/local/etc/php.ini-recommended
Editphp.inifile:short_open_tag=On upload_max_filesize=6M error_log=syslog
To configure Apache for PHP, install additional ports (as required):
- Install PHP PCRE port:
cd /usr/ports/devel/php5-pcre make isntall make clean
- Install PHP5 Mysqli
dc /usr/ports/databases/php5-mysqli make isntall make clean
- install php5-ctype
cd /usr/ports/textproc/php5-ctype make config make install make clean
- install php5-gd
cd /usr/ports/graphics/php5-gd make install make clean
(accept default checkboxes settings) - install php5-zlib
make install make clean
- Install PHP PCRE port:
Enable Apache, PHP and MySQL at boot:
Edit/etc/rc.confand add the following lines:apache22_enable="YES" mysql_enable="YES"
To avoid warning when apache starts, also add this line:accf_http_load="YES"
Configure
Monthly (seenewsyslog.confto rotate Apache httpd logs:man newsyslog.conffor more info):
add lines to the/etc/newsyslog.conf:/var/log/my_log_filename.log 644 10000 * $M1D0 J ...
Tips for create a backup script on FreeBSD/Linux:
I needed to create a simple script that periodically makes backup copy of some working directories and files. This can be dine usingnewsyslogwhich will rotate log files (0...9), however I would prefer if log filenames have a date in them. Here is how it can be done in the script:#delete archives older than X days: find /bkpdir/ -name '*.tbz2' -maxdepth 1 \! \( -newermt '20 days ago' \) -delete # make 'dated' backup: tar -cyf /bkpdir/system_bkp_$(date +%Y-%m-%d).tbz2 /bkpdir/bkp
To setup periodic backup procedure that executes yourrun_bkpbackup script, add lines to the/etc/crontabfile:15 6 * * 1 root /root/run_bkp 15 6 * * 4 root /root/run_bkp


Robot Building
Space / Sci-Fi - Space exploration, Dawn Mission, long-term space missions, terraforming, space art, ...
My Work
FreeBSD
Our Small Cabin
Travel