Posts Tagged ‘FreeBSD’

Change Default SSH Port to Protect FreeBSD server from daily spam attack

Saturday, September 18th, 2010

Change Default SSH Port to Protect your FreeBSD server from daily spam attack.

# ee /etc/ssh/sshd_config

look for line #port 22 and change it to port 1234 then press Esc, save and exit.

reboot the server

#shutdown -r now

or type this command to reload SSH

# /etc/rc.d/sshd reload

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 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.

Top 10 reasons to use FreeBSD

Sunday, March 7th, 2010
  1. FreeBSD is open source free of charge, i.e no license cost like windows server or Red Hat Enterprise.
  2. It’s Built with security and performance in mind.
  3. Very Stable server.
  4. Very optimized for resources, you can build a server with 256 MB ram and celeron processor.
  5. You can utilize it as a Mail server, Web Server, DataBase server, File system server.
  6. You can use Unix and Linux.
  7. Very easy and flexible update and install through ports.
  8. You can get a fully dedicated server with FreeBSD for just a 30$ per Month.
  9. Many big organizations world wide using FreeBSD like Yahoo.
  10. I like FreeBSD.