Archive for the ‘FreeBSD’ Category

Building secure Email Server

Wednesday, September 15th, 2010

FreeBSD comes by default with sendmail email server installed, but its not secure and scalable enough.

Building secure Email Server from scratch is a huge task, because it need many component to be installed and configured.

My objective was to build a secure, fast, reliable email server, very less and optimized system resource, using SSL, have a web interface for administration, web interface for clients, can be accessed by email clients application like Microsoft outlook and Microsoft outlook express, also my email server should be protected against spam and virus scan capabilities.

Secure Email Server component include:

  • Install and configure Apache  server.
  • Install and configure PHP.
  • Install and configure MySql server.
  • Create SSL/TLS certificate using openssl.
  • Install and configure Dovecot POP3/IMAP server.
  • Install and configure PostFix the alternative to Sendmail.
  • Install and configure PostFixAdmin.
  • Install and configure squirrelmail.
  • Install and configure SpamAssassin.

one of the best articles I found on the web, which go step by step to install a secure email server on FreeBSD here

Install Drupal on FreeBSD step by step

Wednesday, June 30th, 2010

Drupal is an open source CMS,
To install drupal on FreeBSD you should have both Apache, and MySQL insalled and runing.

  1. Download Drupal using #wget http://ftp.drupal.org/files/projects/drupal-6.17.tar.gz
  2. decompress the file using #tar -zxvf drupal-6.17.tar.gz
  3. move the folder to your web home directory #mv drupal-6.17 /www/home/
  4. change the current directory to the new folder #cd /www/home/drupal-6.17
  5. copy the configuration file #cp sites/default/default.settings.php sites/default/settings.php
  6. change folder and file permission #chmod a+w sites/default/settings.php, #chmod a+w sites/default
  7. login to mysql database console #mysql -u user -p
  8. create a new database mysql>create database drupal6;
  9. change current database mysql>use mysql;
  10. create a new user mysql>create user drupal;
  11. give the required permission to the new user mysql>GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON drupal6.*  TO ‘drupal’@'localhost’ IDENTIFIED BY ‘pass@word’;
  12. add new section virtual alias in Apache server #ee /usr/local/etc/apache22/httpd.conf
  13. restart Apache server #/usr/local/sbin/apachectl stop , #/usr/local/sbin/apachectl start
  14. Browse your new web site and enter the database information.
  15. installation will start and a message will come : All necessary changes to ./sites/default and ./sites/default/settings.php  have been made, so you should remove write permissions.
  16. remove permission using #chmod a-w sites/default/settings.php,#chmod a-w sites/default
  17. complete adding administrator account.
  18. enjoy drupal.

FreeBSD server status

Wednesday, June 9th, 2010

There is many tools and commands you can use to monitor the status of FreeBSD server like :

  • #top   , it will display the top processes on the system and  continue updates this  information, to exist press Ctrl+C
  • #last , it will list the sessions in reverse time order.
  • # cat /var/log/auth.log , it will disply auto.log info.
  • #cat /var/log/messages , it will disply messages info.
  • #netstat -r , it display a list of network status.
  • #freecolor , it display used/free Physical , and Swap memory.
  • #ps , to display process status.

Creating New Web Site Using Apache Server on FreeBSD

Monday, June 7th, 2010

Steps Creating New Web Site Using Apache Server on FreeBSD:

  1. Create a new folder for the new web site for example /usr/local/www/mysite.com.
  2. mkdir /usr/local/www/mysite.com
  3. grant the required rights to this folder.
  4. chown www:www /usr/local/www/mysite.com
  5. Edit Apache configuration file.
  6. ee /usr/local/etc/apache22/httpd.conf
  7. add new section for the new web site
  8. <VirtualHost x.x.x.x:80>
    ServerName mysite.com
    ServerAlias wwww.mysite.com
    DocumentRoot /usr/local/www/mysite.com
    <Directory /usr/local/www/mysite.com>
    Options FollowSymLinks MultiViews Includes
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
    </VirtualHost>
    
  9. Restart Apache server.
  10. /usr/local/sbin/apachectl stop
  11. /usr/local/sbin/apachectl start
  12. be sure DNS is ready or you add a new zone to your bind DNS server.

FreeBSD view system log

Tuesday, March 9th, 2010

One of the daily operations as FreeBSD administrator is to check system log and system resources usage, also system logs are my favorite friend to debug and solve system problems.

Here  a summary list for commands used to check system log.

  1. cat /var/log/messages will display all the system log
  2. tail -f /var/log/messages will display the tail of system log, use Ctrl+C to exit.
  3. less /var/log/messages will display system log page by page, press Q to exit.
  4. cat /var/log/messages | grep error will display only the lines contain the keyword error.
  5. vi /var/log/messages use :q to exit vi viewer (vi is the default editor that comes with the UNIX operating)

Other important logs you should check:

  1. cat /var/log/auth.log | grep error
  2. cat /var/log/maillog | grep error

Configure Apache Server on FreeBSD

Monday, March 8th, 2010
  1. Edit configuration file.
  2. ee /usr/local/etc/apache22/httpd.conf
  3. Do the required modifications.
  4. Restart Apache server.
  5. /usr/local/sbin/apachectl stop
  6. /usr/local/sbin/apachectl start

FreeBSD Editor ee

Monday, March 8th, 2010

Fast easy to use character mode editor, its installed by default in FreeBSD.

use the following command to start the editor

#ee filename

ex:

#ee /etc/rc.conf

if filename exists ee will open,show it, and display no of lines.

if filename not exists ee will display message new file.

some commands commonly used in ee editor:

  1. Press Esc key to go out and leave the editor, ee will show pop-up menu with all possible actions.
  2. Press Ctrl + Y if you need to search for something, it will allow editing the search criteria and jump to first occurance .
  3. Press Ctrl+ X if you need to continue search for last criteria.
  4. Press Ctrl+ K to delete a line.

Upgrade WordPress Multi User Error

Sunday, March 7th, 2010

When I tried to update wordpress multi user on my FreeBSD ver 8.0 I received the following error:

Downloading update from http://mu.wordpress.org/wordpress-mu-2.9.2.zip.

Unpacking the update.

Abort class-pclzip.php : Missing zlib extensions

to fix it simply execute the following commands as a root user:

  1. # cd /usr/ports/archivers/php5-zlib
  2. # make install clean
  3. # apachectl restart

building php5-zlib give the following note: The following line has been added to your /usr/local/etc/php/extensions.ini configuration file to automatically load the installed extension: extension=zlib.so

that set, and upgrade run smoothly.

FreeBSD Commands

Sunday, March 7th, 2010

Here is summary list for FreeBSD commands usually need and use:

  1. #pwd : get the current directory.
  2. #whoami get current user.
  3. #ls : list the files, only file names will be listed , its like dir command in the DOS.
  4. #ls -l : list the files, with detail information about files like file permission, owner, group, date, and size  , its like dir command in the DOS.
  5. #cd : to change directory.
  6. #man command: get the manual syntax and usage for the given command.
  7. #man -k keyword: search the manual for the given keyword.
  8. #cat filename: view the contents of the given file.
  9. #locate filename: serach for the location of the given file, its very fast.
  10. #/usr/libexec/locate.updatedb: to update locate database lookup file.
  11. #ee filename: edit the given file.
  12. #shutdown -r now: reboot the server immediately.
  13. #su: switch the current user to the root user.
  14. #fetch url: to download a url using http of ftp.
  15. #cp oldfilename newfilename: copy a file or directory to a new one.
  16. #cp -R oldfilename newfilename: copy a file or directory to a new one and all sub directories.
  17. #rm filename : delete and remove a file or directory.
  18. #rm -R filename : delete and remove a file or directory and all sub directories.
  19. #mv oldfilename newfilename: move  file to a new location.
  20. #mv -R oldfilename newfilename: move  file to a new location and all sub directories.
  21. #find /size + 100000k search for files that is larger than 100000k.

Why I decided to use FreeBSD

Sunday, March 7th, 2010

When I got my Windows server 2008 web edition dedicated server, I was surprised that there is no DNS server and there is no pop3 service. my all previous experience was dedicated to Microsoft family only, but the world is more open and bigger than Microsoft, Microsoft open the door to me for open source when they close the services that was there in 2003 server.

I search the web for free DNS server and found bind9.net and this was the start with the open source world, bind9 working for both Windows and Unix based servers.

Later on I decided to get another dedicated server to be DNS backup server, secure mail, files backup server with three conditions:

  1. Can be a DNS server, Web Server, secure email server.
  2. The cost.
  3. Can run Mono, Mono is an open source project for Microsoft .Net framework to run on Unix based system.

My hosting company was providing FreeBSD, Enterprise Linux – CentOS, Debian, and Ubuntu Server.

Hosting company recommendation was  Enterprise Linux – CentOS.

I search the web to get comparison between this Unix based operating system, I found all of them is good and doing the required two points, and the choice depend on my selection, so I decided to read on Mono web site, what is the supported platform I found almost all is supported but I found separate section talking about FreeBSD.

I feel its hard to get a decision, I pray Istikhara; Istikhara is a recommended prayer for Muslems before they got a major decision, you can read more about it here

So I decided to get my dedicated server box as FreeBSD, and I found it more than I expect, sure at start life was not easy at all, but day by day its a proven choice.