Linux Mail Servers

Manual Settings
~~~~~~~~~~~~

Mail Server Username: no-reply+domain.com
Incoming Mail Server: mail.domain.com
Incoming Mail Server: (SSL) host200.hostmonster.com
Outgoing Mail Server: mail.domain.com (server requires authentication) port 26
Outgoing Mail Server: (SSL) host200.hostmonster.com (server requires authentication) port 465
Supported Incoming Mail Protocols: POP3, POP3S (SSL/TLS), IMAP, IMAPS (SSL/TLS)
Supported Outgoing Mail Protocols: SMTP, SMTPS (SSL/TLS)

Warning: Changing MX to something besides domain.com will prevent us from managing your mail. The email will no longer be sent to this server.

Increase RAM size
~~~~~~~~~~~~~~

Some time there is problem with kernel.. as rams physically is 8GB. The reason for 3GB RAM is kernel not updated, so the high volume memory is not recognized. Try this command to update ram size:

# yum install kernel-PAE

http://www.cyberciti.biz/tips/category/mail-server

Amazon EBS

Amazon Elastic Block Storage (EBS)

We can use Amazon EBS just like as the CD/DVD/Pen Drives on our PC/Laptops Servers for backup or data transfer…
EBS can attach to an EC2 instance, we can use EBS to save work files in it.. for it we have to mount it in the instance after backup we can unmount it, and detach it.
We can use the volume afterward by mounting it in another instance but different instances at the same time can not use same EBS volume.

Starting an Instance

# ec2-describe-images -o self -o amazon | grep machine
# ec2-add-keypair gsg-keypair (save this keypair for connecting instance via SSH)
# chmod 600 id_rsa-gsg-keypair ; ls -l id_rsa-gsg-keypair
# ec2-run-instances ami-235fba4a -k gsg-keypair
# ec2-describe-instances i-ae0bf0c7

Authorize ports to connect remotely…
# ec2-authorize default -p 22
# ec2-authorize default -p 80

Connect to instance
# ssh -i id_rsa-gsg-keypair root@ec2-67-202-51-223.compute-1.amazonaws.com

Create the Volume
# ec2-create-volume –size 1 -z us-east-1c
Create this volume in same availability zone

# ec2-describe-volumes vol-4771e479

Attaching the Volume
# ec2-attach-volume vol-4771e479 -i i-ae0bf0c7 -d /dev/sda

Formatting the Volume
# ssh -i id_rsa-gsg-keypair root@ec2-67-202-51-223.compute-1.amazonaws.com
# ls /dev
# yes | mkfs -t ext3 /dev/sda

Mounting the Volume
# mkdir /mnt/svnlabs-data
# mount /dev/sdh /mnt/svnlabs-data

Put a file on the volume
# vi /mnt/svnlabs-data/svnlabs.txt (put content here)

Unmounting the Volume
# cd ~
# umount /mnt/svnlabs-data

Detach the Volume
# ec2-detach-volume vol-4771e479 -i i-ae0bf0c7 -d /dev/sda

As we attach this volume to other instance we will get our svnlabs-data folder to new instance…

svnlabs will post some new articles on “Amazon Web Services” 😉 subscribe to svnlabs feeds

Crontab Command Line

crontab Crontab Command Line

1. dump the content of the existing crontab to a file
# crontab > /tmp/dump
2. echo “your lines” >> to the corntab file
# echo ” 00 1 * * * /monitor_file_system 2>/dev/null” >> /tmp/dump
3. import the new crontab
# crontab /tmp/dump

other option….
# crontab -e
It will open a editor, add job here like
00 1 * * * /monitor_file_system 2>/dev/null

Set cronjob from other server:
# crontab -e
0 0 * * * curl http://www.domain.com/svnlabs.php

here svnlabs.php file is located on different server…

and save this crontab files…. now cronjob successfully installed 🙂

Couldn’t find video filter ‘x264’

X264
X264

x264 is a free software library for encoding video streams into the H.264/MPEG-4 AVC format. It is released under the terms of the GNU General Public License.

x264 itself provides a command line interface as well as a library-level interface.

x264 is used to encode video files in mp4, m4v, h.264 (HD) output format.

Install x264
------------

*  Download the latest snapshot(tarball) here:
# wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20090113-2245.tar.bz2

* Extract tarball
# bzip2 -cd x264-snapshot-20090113-2245.tar.bz2 | tar xvf -
# cd x264-snapshot-20090113-2245

* Build and install
# ./configure
# make
# make install

Some problems with mplayer & x264

Install/compile mplayer with x264 support

-x264encopts is not an MEncoder option
Checking for x264 ... no (in libavcodec: no)   (./configure)

# svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

# cd /usr/local/src/mplayer

# svn update

# ./configure

After configure make sure you got

Checking for x264 ... yes (in libavcodec: yes)

# make && make install

Try latest version of video tools ffmpeg, mplayer, mencoder, flvtool2, mediainfo  🙂

Find correct path where you installed these components try …..

# locate command

“make sure you are using /usr/bin/mencode and NOT /usr/lib/bin/mencode”

🙂

sh: /mencoder: No such file or directory

This is the problem caused due to PHP safe_mode restrictions to execute linux commands.

If safe mode is on we can not run linux commands by exec() PHP function.

Try safe mode Off when you want to execute linux tools with PHP….

Disable dangerous function from executing to exec().. that will cause application non functional 🙁

# php mencoder.php

sh: /mencoder: No such file or directory

# cat mencoder.php
<?php exec("mencoder -ovc help"); ?>
# mencoder -ovc help

PHP Safe Mode
PHP Safe Mode

Create TCPDF PHP Fonts

TCPDF supports TrueTypeUnicode (UTF-8 Unicode), OpenTypeUnicode, TrueType, OpenType, Type1, CID-0 and Core (standard) fonts.

You will find font creation utility at fonts/utils of TCPDF… copy desired font to fonts/utils/svnlabs.ttf

* For TrueTypeUnicode

# cd /var/www/html/tcpdf/fonts/utils

# ttf2ufm -a -F svnlabs.ttf

# php -q makefont.php svnlabs.ttf svnlabs.ufm

* For embedded fonts to tcpdf PDF file.. copy the resulting svnlabs.php, svnlabs.z and svnlabs.ctg.z to fonts folder

Uses:

<?php

……..

$pdf->SetFont(‘svnlabs’,’I’,8);

……….

?>

Exclude folders from zip – tar

TARTape Archive  (application/x-tar)

tar svnlabs
TAR - svnlabs

A common archive format used on Unix-like systems. Generally used in conjunction with compressors such as gzip, bzip2, compress or xz to create .tar.gz, .tar.bz2, .tar.Z or tar.xz files.

# tar -cvvf foo.tar foo/ –exclude=”/home/svnlabs”

# tar -cvzpP –file=/home/backup.tar.gz –exclude={/dev/*,/proc/*,/sys/*,/tmp/*} /

tar work with directory “/” except for /dev, /proc, /sys, /tmp 🙂

Install MP4Box

MP4Box is a multimedia package used for  conversion, splitting, hinting, dumping and others.

zlib is a software library used for data compression. zlib was written by Jean-Loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compression program.

Source: http://sourceforge.net/projects/gpac/files/

Download latest “gpac-0.4.5.tar.gz” & “gpac_extra_libs-0.4.5.tar.gz” from above link……

# wget http://nchc.dl.sourceforge.net/project/gpac/GPAC/GPAC%200.4.5/gpac-0.4.5.tar.gz
# wget http://nchc.dl.sourceforge.net/project/gpac/GPAC%20extra%20libs/GPAC%20extra%20libs%200.4.5/gpac_extra_libs-0.4.5.tar.gz

# tar -zxf gpac-0.4.5.tar.gz
# tar -zxf gpac_extra_libs-0.4.5.tar.gz
# cd gpac_extra_libs
# cp -r * ../gpac/extra_lib
# cd ../gpac
# chmod +x configure

# yum install zlib*

# ./configure
# make lib
# make apps
# make install lib
# make install
# cp bin/gcc/libgpac.so /usr/lib

Install git on linux

Git is a free distributed revision control, or software source code management project with an emphasis on being fast. Git was initially designed and developed by Linus Torvalds for Linux kernel development.

Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.

Install git
# wget http://www.kernel.org/pub/software/scm/git/git-1.6.1.tar.gz
# tar zxvf git-1.6.1.tar.gz
# cd git-1.6.1
# ./configure
# make && make install

Uses:
# git clone git://central.server/path/to/proj.git

Sites:
http://git-scm.com/
http://www-cs-students.stanford.edu/~blynn/gitmagic/index.html

Profile:
http://github.com/svnlabs

Install JAVA Tomcat on Linux

Installation of Java

Login to server as root
# cd /opt

Download jdk 6 linux rpm bin package from sun (Java SE Development Kit (JDK))
http://java.sun.com/javase/downloads/index.jsp
http://java.sun.com/javase/downloads/widget/jdk6.jsp

# chmod 777 jdk-6u17-linux-i586-rpm.bin
# ./jdk-6u17-linux-i586-rpm.bin

Follow the onscreen instructions to complete jdk installation…. press space ….. press yes….. and Enter

Now we will find JDK folder at /usr/java/jdk1.6.0_17

Installation TomCat

Download tomcat source files and extract…

# wget http://www.trieuvan.com/apache/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.tar.gz
# tar xzf apache-tomcat-6.0.20.tar.gz
# ls

Move tomcat to /usr/java/tomcat/

# mv apache-tomcat-6.0.20 tomcat
# mv tomcat /usr/java/
# cd /usr/java/tomcat/

Set CLASSPATH for JAVA & TOMCAT

# vi /etc/profile    (set class path)

add source PATH to /etc/profile

export JAVA_HOME=/usr/java/jdk1.6.0_17
export CATALINA_HOME=
/usr/java/tomcat
export PATH=$JAVA_HOME/bin:$PATH

# source /etc/profile

Start tomcat server….

# /usr/java/tomcat/bin/startup.sh

Start/Stop Tomcat

# cd /usr/java/tomcat/bin
# ./shutdown.sh
# ./startup.sh

Check tomcat status

# netstat -ntlp|grep 8080

Enjoy new server 🙂