Tuesday, October 9, 2012

Monitoring Bandwidth with VNstat

VNstat is a bandwidth monitoring tool that will let you monitor your bandwidth and provide daily, weekly and monthly tracking metrics.

To install and setup Vnstat, you will need to follow the steps in this article.

Log into your linux server and type the following command.wget http://humdi.net/vnstat/vnstat-1.10.tar.gz

Next to uncompress the file you will need to run the following command. tar -zxvf vnstat-1.10.tar.gz

Now that you have the file uncompressed, you will need to install Vnstat. To do this, you will need to navigate to the VNstat directory and run the following command.
make & make install

Now that it has been installed, you will first need to run "vnstat --iflist" on your server, so you know the name of your network adaptors. vnstat --iflist

You will now be presented with the any available adaptors on your server. Available interfaces lo eth0 sit0

Now that you know what adaptors you have on your server, you will need to tell VNstat to create a small database for that adapator. To do this, simply type /usr/bin/vnstat -u -i then the adaptor name. So for our example, we would run the following /usr/bin/vnstat -u -i eth0 If you have multiple adaptors, you will need to do this for each adaptor. However you do not have to if you only want to monitor specific adaptors.

Next, make sure that Vnstat restarts whenever you reboot your server. To do this, add the service to your server's "Chkconfig" list by running the following command.

chkconfig --add vnstat
chkconfig vnstat on

Now you can access Vnstat by logging into the server at anytime and typing "vnstat". Doing so will give you a realtime status of your bandwidth.
Sunday, October 7, 2012

htaccess-tricks

http://perishablepress.com/stupid-htaccess-tricks/#sec6

Set the default language and character set ^

Here is an easy way to set the default language for pages served by your server (edit the language to suit your needs):
# set the default language
DefaultLanguage en-US
Likewise, here we are setting the default character set (edit to taste):
# set the default character set
AddDefaultCharset UTF-8

 

Declare specific/additional MIME types ^

# add various mime types
AddType application/x-shockwave-flash .swf
AddType video/x-flv .flv
AddType image/x-icon .ico

 

Send character set and other headers without meta tags ^

# send the language tag and default character set
# AddType 'text/html; charset=UTF-8' html
AddDefaultCharset UTF-8
DefaultLanguage en-US

 

Limit server request methods to GET and PUT ^

# limit server request methods to GET and PUT
Options -ExecCGI -Indexes -All
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|HEAD) RewriteRule .* - [F]

 

Selectively process files according to server request method ^

# process files according to server request method
Script PUT /cgi-bin/upload.cgi
Script GET /cgi-bin/download.cgi

 

Execute various file types through a cgi script ^

For those special occasions where certain file types need to be processed with some specific cgi script, let em know who sent ya:
# execute all png files via png-script.cgi
Action image/png /cgi-bin/png-script.cgi

 

Security [ ^ ]

 

Prevent Access to .htaccess ^

Add the following code block to your htaccess file to add an extra layer of security. Any attempts to access the htaccess file will result in a 403 error message. Of course, your first layer of defense to protect htaccess files involves setting htaccess file permissions via CHMOD to 644:
# secure htaccess file
htaccess>
 order allow,deny
 deny from all

 

Prevent Access to a Specific File ^

To restrict access to a specific file, add the following code block and edit the file name, “secretfile.jpg”, with the name of the file that you wish to protect:
# prevent viewing of a specific file

 order allow,deny
 deny from all

 

Prevent access to multiple file types ^

To restrict access to a variety of file types, add the following code block and edit the file types within parentheses to match the extensions of any files that you wish to protect:

 Order Allow,Deny
 Deny from all

 

Prevent Unauthorized Directory Browsing ^

Prevent unauthorized directory browsing by instructing the server to serve a “xxx Forbidden – Authorization Required” message for any request to view a directory. For example, if your site is missing it’s default index page, everything within the root of your site will be accessible to all visitors. To prevent this, include the following htaccess rule:
# disable directory browsing
Options All -Indexes
Conversely, to enable directory browsing, use the following directive:
# enable directory browsing
Options All +Indexes
Likewise, this rule will prevent the server from listing directory contents:
# prevent folder listing
IndexIgnore *
And, finally, the IndexIgnore directive may be used to prevent the display of select file types:
# prevent display of select file types
IndexIgnore *.wmv *.mp4 *.avi *.etc

 

Change Default Index Page ^

This rule tells the server to search for and serve “business.html” as the default directory index. This rule must exist in the htaccess files of the root directory for which you wish to replace the default index file (e.g., “index.html”):
# serve alternate default index page
DirectoryIndex business.html
This rule is similar, only in this case, the server will scan the root directory for the listed files and serve the first match it encounters. The list is read from left to right:
# serve first available alternate default index page from series
DirectoryIndex filename.html index.cgi index.pl default.htm

 

Disguise Script Extensions ^

To enhance security, disguise scripting languages by replacing actual script extensions with dummy extensions of your choosing. For example, to change the “.foo” extension to “.php”, add the following line to your htaccess file and rename all affected files accordingly:
# serve foo files as php files
AddType application/x-httpd-php .foo
# serve foo files as cgi files
AddType application/x-httpd-cgi .foo

 

Limit Access to the Local Area Network (LAN) ^

# limit access to local area network

 order deny,allow
 deny from all
 allow from 192.168.0.0/33

 

Secure Directories by IP Address and/or Domain ^

In the following example, all IP addresses are allowed access except for 12.345.67.890 and domain.com:
# allow all except those indicated here

 order allow,deny
 allow from all
 deny from 12.345.67.890
 deny from .*domain\.com.*

In the following example, all IP addresses are denied access except for 12.345.67.890 and domain.com:
# deny all except those indicated here

 order deny,allow
 deny from all
 allow from 12.345.67.890
 allow from .*domain\.com.*


This is how to block unwanted visitors based on the referring domain. You can also save bandwidth by blocking specific file types — such as .jpg, .zip, .mp3, .mpg — from specific referring domains. Simply replace “scumbag” and “wormhole” with the offending domains of your choice:
# block visitors referred from indicated domains

 RewriteEngine on
 RewriteCond %{HTTP_REFERER} scumbag\.com [NC,OR]
 RewriteCond %{HTTP_REFERER} wormhole\.com [NC,OR]
 RewriteRule .* - [F]

 

Prevent or allow domain access for a specified range of IP addresses ^

There are several effective ways to block a range of IP addresses via htaccess. This first method blocks an IP range specified by their CIDR (Classless Inter-Domain Routing) number. This method is useful for blocking mega-spammers such as RIPE, Optinet, and others. If, for example, you find yourself adding line after line of Apache deny directives for addresses beginning with the same first few numbers, choose one of them and try a whois lookup. Listed within the whois results will be the CIDR value representing every IP address associated with that particular network. Thus, blocking via CIDR is an effective way to eloquently prevent all IP instances of the offender from accessing your site. Here is a generalized example for blocking by CIDR (edit values to suit your needs):
# block IP range by CIDR number
 

 order allow,deny
 allow from all
 deny from 10.1.0.0/16
 deny from 80.0.0/8

Likewise, to allow an IP range by CIDR number:
# allow IP range by CIDR number

 order deny,allow
 deny from all
 allow from 10.1.0.0/16
 allow from 80.0.0/8

Another effective way to block an entire range of IP addresses involves truncating digits until the desired range is represented. As an IP address is read from left to right, its value represents an increasingly specific address. For example, a fictitious IP address of 99.88.77.66 would designate some uniquely specific IP address. Now, if we remove the last two digits (66) from the address, it would represent any address beginning with the remaining digits. That is, 99.88.77 represents 99.88.77.1, 99.88.77.2, … 99.88.77.99, …etc. Likewise, if we then remove another pair of digits from the address, its range suddenly widens to represent every IP address 99.88.x.y, where x and y represent any valid set of IP address values (i.e., you would block 256*256 = 65,536 unique IP addresses). Following this logic, it is possible to block an entire range of IP addresses to varying degrees of specificity. Here are few generalized lines exemplifying proper htaccess syntax (edit values to suit your needs):
# block IP range by address truncation

 order allow,deny
 allow from all
 deny from 99.88.77.66
 deny from 99.88.77.*
 deny from 99.88.*.*
 deny from 99.*.*.*

Likewise, to allow an IP range by address truncation:
# allow IP range by address truncation

 order deny,allow
 deny from all
 allow from 99.88.77.66
 allow from 99.88.77.*
 allow from 99.88.*.*
 allow from 99.*.*.*

Block or allow multiple IP addresses on one line ^

Save a little space by blocking multiple IP addresses or ranges on one line. Here are few examples (edit values to suit your needs):
# block two unique IP addresses
deny from 99.88.77.66 11.22.33.44
# block three ranges of IP addresses
deny from 99.88 99.88.77 11.22.33
Likewise, to allow multiple IP addresses or ranges on one line:
# allow two unique IP addresses
allow from 99.88.77.66 11.22.33.44
# allow three ranges of IP addresses
allow from 99.88 99.88.77 11.22.33

Miscellaneous rules for blocking and allowing IP addresses ^

Here are few miscellaneous rules for blocking various types of IP addresses. These rules may be adapted to allow the specified IP values by simply changing the deny directive to allow. Check ’em out (edit values to suit your needs):
# block a partial domain via network/netmask values
deny from 99.1.0.0/255.255.0.0
# block a single domain
deny from 99.88.77.66
# block domain.com but allow sub.domain.com
order deny,allow
deny from domain.com
allow from sub.domain.com

Use of Find Command in Unix

To find the largest 10 files (linux/bash):

# find . -type f -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}


To find the largest 10 directories:

# find . -type d -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}

Only difference is -type {d:f}. No type for combined results.

For a quick view:

# du | sort -n

Find directory size more than 500MB

# find . -type f -size +500000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

Find OUT large hists form IP

# awk '{print $1};' /var/log/httpd/access_log | sort | uniq -c | sort -rn | head

Find out directory files count

#  ls -l | awk '!/^d/{print }' | wc -l

#  ls -la |wc -l

#  find . |wc –l

Find file which older than 30 days or modify

# find . -mtime +30

Delete old files older than x days with subdirectories
 
# find . -mtime +10 -exec rm {} \; 

This will show you how to find the ten biggest files / folders on your linux system

# du -a / | sort -n -r | head -n 10

You can use the command to find the biggest files in a specific location like this

# du -a /var/www | sort -n -r | head -n 10

And you can return more than ten results like this

# du -a /var/www | sort -n -r | head -n 25 

Large Files

Find files larger than 10MB in the current directory downwards…
find . -size +10000000c -ls
Find files larger than 100MB…
find . -size +100000000c -ls

Old Files

Find files last modified over 30days ago…
find . -type f -mtime 30 -ls
Find files last modified over 365days ago…
find . -type f -mtime 365 -ls
Find files last accessed over 30days ago…
find . -type f -atime 30 -ls
Find files last accessed over 365days ago…
find . -type f -atime 365 -ls

Find Recently Updated Files

There have been instances where a runaway process is seemingly using up any and all space left on a partition. Finding the culprit file is always useful.
If the file is being updated at the current time then we can use find to find files modified in the last day…
find  . -type f -mtime -1 -ls
Better still, if we know a file is being written to now, we can touch a file and ask the find command to list any files updated after the timestamp of that file, which will logically then list the rogue file in question.
touch testfile
find .  -type f -newer testfile -ls

Finding tar Files

A clean up of redundant tar (backup) files, after completing a piece of work say, is sometimes forgotten. Conversely, if tar files are needed, they can be identified and duly compressed (using compress or gzip) if not already done so, to help save space. Either way, the following lists all tar files for review.
find . -type f -name "*.tar" -ls
find . -type f -name "*.tar.Z" -ls

Large Directories

List, in order, the largest sub-directories (units are in Kb)…
du -sk * | sort -n
Sometimes it is useful to then cd into that suspect directory and re-run the du command until the large files are found.

Removing Files using Find

The above find commands can be edited to remove the files found rather than list them. The “-ls” switch can be changed for “-exec rm {}\;”=.
e.g.
find . -type f -mtime 365 -exec rm {} \;
Friday, March 30, 2012

Master-Slave Replication

For master

[mysqld]
#set-variable = max_connections=500
safe-show-database

skip-locking
key_buffer = 100M
max_allowed_packet = 64M
log-error=/var/log/mysql/mysql-error.log
long_query_time = 3
log-slow-queries=/var/log/mysql/mysql-slow.log
table_cache = 512
sort_buffer_size = 10240K
read_buffer_size = 10240K
read_rnd_buffer_size = 10240K
net_buffer_length = 10240k
myisam_sort_buffer_size = 100M
max_connections=2048
set-variable = max_user_connections=2048
set-variable = max_connect_errors=999999
set-variable = query_cache_size=512M
query_cache_limit = 512M
set-variable = join_buffer=512M
thread_cache_size = 1024

log-bin=/var/lib/mysql/binlog
#binlog-do-db=systemWcell
#binlog-ignore-db=mysql
#binlog-ignore-db=test

server-id=4

create mysql user for replication
GRANT ALL PRIVILEGES ON *.* TO repl@replication server ip ;
SET PASSWORD FOR repl@replication server ip =PASSWORD('QHeqJ3TH');
FLUSH PRIVILEGES;

mysql> show master status\G
*************************** 1. row ***************************
File: binlog.000013
Position: 453
Binlog_Do_DB:
Binlog_Ignore_DB:
1 row in set (0.00 sec)

For slave
[mysqld]
set-variable = max_connections=500
safe-show-database

skip-locking
key_buffer = 100M
max_allowed_packet = 64M
log-error=/var/log/mysql/mysql-error.log
long_query_time = 3
log-slow-queries=/var/log/mysql/mysql-slow.log
table_cache = 512
sort_buffer_size = 10240K
read_buffer_size = 10240K
read_rnd_buffer_size = 10240K
net_buffer_length = 10240k
myisam_sort_buffer_size = 100M
max_connections=2048
set-variable = max_user_connections=2048
set-variable = max_connect_errors=999999
set-variable = query_cache_size=512M
query_cache_limit = 512M
set-variable = join_buffer=512M
thread_cache_size = 1024

server-id=7

#binlog-do-db=systemWcell
replicate-do-db=systemWcell ---------------------------- DB Name
slave_skip_errors=all
#relay-log=/var/lib/mysql/relaylog


" CHANGE MASTER TO
" MASTER_HOST='Master IP,
" MASTER_USER='repl',
" MASTER_PASSWORD='QHeqJ3TH',
" MASTER_PORT=3306,
" MASTER_LOG_FILE='bin-log.000013',------------------------------ bin log possition
" MASTER_LOG_POS= 453;



+---------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------+----------+--------------+------------------+
| binlog.000002 | 2397878 | | |
+---------------+----------+--------------+------------------+
1 row in set (0.00 sec)

Mysql > Start slave;
Mysql> show slave status;

HA Configuration

Installation:

On machine1 and machine2 install Heartbeat and needed utilities. You may need to review the packages you have available using ‘yum list | grep drbd’. These are for CentOS 5.5. You may also need to reboot after this step.

# yum -y install gnutls*
# yum -y install ipvsadm*
# yum -y install heartbeat*
# yum -y install heartbeat.x86_64

Configuration:

Edit /etc/sysctl.conf and set net.ipv4.ip_forward = 1

# vi /etc/sysctl.conf

Controls IP packet forwarding net.ipv4.ip_forward = 1

# /sbin/chkconfig --level 2345 heartbeat on
# /sbin/chkconfig --del ldirectord

Configure HA:

You need to setup the following configuration files on both machines:

# vi /etc/ha.d/ha.cf

#/etc/ha.d/ha.cf content
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694 # If you have multiple HA setup in same network.. use different ports
bcast eth0 # Linux
auto_failback on # This will failback to machine1 after it comes back
ping 192.168.2.1 # The gateway
apiauth ipfail gid=haclient uid=hacluster
node db1.grennan.com
node db2.grennan.com

On both machines

NOTE: Assuming 192.168.2.15 is virtual IP for your MySQL resource and mysqld is the LSB resource agent. The host name (db2) should be the secondary server’s name.

# vi /etc/ha.d haresources

# /etc/ha.d/haresources content
db2.grennan.com LVSSyncDaemonSwap::master Paddr2::192.168.2.15/24/eth0 rbddisk::db Filesystem::/dev/drbd1::/data::ext3 mysqld

# vi /etc/ha.d/authkeys

#/etc/ha.d/authkeys content
auth 2
2 sha1 BigSecretKeyks9wjwlf9gskg905snvl

Now, make your authkeys secure:

# chmod 600 /etc/ha.d/authkeys

Check your work:

On both machines, one at a time, stop MySQL and make sure MySQL does not start when the system reboots (init 6).

If it does, you may need to remove it from the init process with:

# /sbin/chkconfig --level 2345 MySQL off

Start Heartbeat.

# service heartbeat start

These commands will give you status about this LVS setup:

# /etc/ha.d/resource.d/LVSSyncDaemonSwap master status
# ip addr sh
# service heartbeat status
# df
# service mysqld status

Access your HA-MySQL server like:

# mysql –h 192.168.2.15

Shutdown machine1 to see MySQL up on machine2. ‘shutdown now’

Start machine1 to see MySQL back on machine1.

Master-Master Replication

Master 1 IP Address : 192.168.0.2
Master 2 IP Address: 192.168.0.3
Database to replicate: db1, db2, and db3


Master 1
On 192.168.0.2

mysql> CREATE USER 'repl'@'192.168.0.3' IDENTIFIED BY 'gmi123W';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.0.3' IDENTIFIED BY 'gmi123W';
mysql> FLUSH PRIVILEGES;

mysql> CREATE USER 'repl'@'192.168.0.%' IDENTIFIED BY 'gmi123W';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.0.%' IDENTIFIED BY 'gmi123W';
mysql> FLUSH PRIVILEGES;


skip-locking
key_buffer = 100M
max_allowed_packet = 64M
log-error=/var/log/mysql/mysql-error.log
long_query_time = 3
log-slow-queries=/var/log/mysql/mysql-slow.log
table_cache = 512
sort_buffer_size = 10240K
read_buffer_size = 10240K
read_rnd_buffer_size = 10240K
net_buffer_length = 10240k
myisam_sort_buffer_size = 100M
max_connections=2048
set-variable = max_user_connections=2048
set-variable = max_connect_errors=999999
set-variable = query_cache_size=512M
query_cache_limit = 512M
set-variable = join_buffer=512M
thread_cache_size = 1024

server-id = 3

master-host = 192.168.0.3
master-user = repl
master-password = gmi123W
master-connect-retry = 30
slave-net-timeout = 30
replicate-do-db = arvind


log-bin = /var/log/mysql/mysql-bin.log
log-bin-index = /var/log/mysql/master-log-bin.index
binlog-do-db = arvind


relay-log = /var/lib/mysqld-relay-bin
relay-log = /var/lib/mysql/slave-relay.log
relay-log-index = /var/lib/mysql/slave-relay-log.index

mysql>USE arvind;
mysql>UNLOCK TABLES;
mysql>FLUSH TABLES WITH READ LOCK;


mysql> CHANGE MASTER TO MASTER_HOST = '192.168.0.3', MASTER_USER = 'repl', MASTER_PASSWORD = 'gmi123W', MASTER_LOG_FILE = 'mysql-bin.000001',

MASTER_LOG_POS=789;

FLUSH PRIVILEGES;

Master2

On 192.168.0.3

mysql> CREATE USER 'repl'@'192.168.0.2' IDENTIFIED BY 'gmi123W';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.0.2' IDENTIFIED BY 'gmi123W';
mysql> FLUSH PRIVILEGES;

mysql> CREATE USER 'repl'@'192.168.0.%' IDENTIFIED BY 'gmi123W';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.0.%' IDENTIFIED BY 'gmi123W';
mysql> FLUSH PRIVILEGES;

skip-locking
key_buffer = 100M
max_allowed_packet = 64M
log-error=/var/log/mysql/mysql-error.log
long_query_time = 3
log-slow-queries=/var/log/mysql/mysql-slow.log
table_cache = 512
sort_buffer_size = 10240K
read_buffer_size = 10240K
read_rnd_buffer_size = 10240K
net_buffer_length = 10240k
myisam_sort_buffer_size = 100M
max_connections=2048
set-variable = max_user_connections=2048
set-variable = max_connect_errors=999999
set-variable = query_cache_size=512M
query_cache_limit = 512M
set-variable = join_buffer=512M
thread_cache_size = 1024

server-id = 4

master-host = 192.168.0.2
master-user = repl
master-password = gmi123W
master-connect-retry = 30
slave-net-timeout = 30
replicate-do-db = arvind

log-bin = /var/log/mysql/mysql-bin.log
log-bin-index = /var/log/mysql/master-log-bin.index
binlog-do-db = arvind

relay-log = /var/lib/mysqld-relay-bin
relay-log = /var/lib/mysql/slave-relay.log
relay-log-index = /var/lib/mysql/slave-relay-log.index


mysql>USE arvind;
mysql>UNLOCK TABLES;
mysql>FLUSH TABLES WITH READ LOCK;

CHANGE MASTER TO MASTER_HOST = '192.168.0.2', MASTER_USER = 'repl', MASTER_PASSWORD = 'gmi123W', MASTER_LOG_FILE = 'mysql-bin.000001', MASTER_LOG_POS=193;

FLUSH PRIVILEGES;




To Check run below query

create database arvind;


use arvind;

INSERT INTO `citnet_patent` ( `patent_id` , `patent_no` , `patent_f_cit_depth1` , `patent_b_cit_depth1` , `patent_rel_depth1` , `patent_matrix_depth1` ,

`patent_f_cit_depth2` , `patent_b_cit_depth2` , `patent_rel_depth2` , `patent_matrix_depth2` , `patent_first_srch_date` , `patent_update_date` ,

`patent_type` )
VALUES (
'5001', 'ep717426', '', '', '', NULL , NULL , NULL , NULL , NULL , NULL , NULL , '0'
);



select * from citnet_patent;

UPDATE `citnet_patent` SET `patent_no` = 'AS717426',
`patent_matrix_depth1` = NULL ,
`patent_f_cit_depth2` = NULL ,
`patent_b_cit_depth2` = NULL ,
`patent_rel_depth2` = NULL ,
`patent_matrix_depth2` = NULL ,
`patent_first_srch_date` = NULL ,
`patent_update_date` = NULL WHERE `patent_id` =5001 LIMIT 1 ;

select * from citnet_patent;
Tuesday, March 13, 2012

SquirrelMail webmail

To install the SquirrelMail webmail client, run...

yum install squirrelmail

... and restart Apache:

/etc/init.d/httpd restart

Then configure SquirrelMail:

/usr/share/squirrelmail/config/conf.pl

We must tell SquirrelMail that we are using Courier-IMAP/-POP3:

SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages

D. Set pre-defined settings for specific IMAP servers

C Turn color off
S Save data
Q Quit

Command >> <-- D


SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
While we have been building SquirrelMail, we have discovered some
preferences that work better with some servers that don't work so
well with others. If you select your IMAP server, this option will
set some pre-defined settings for that server.

Please note that you will still need to go through and make sure
everything is correct. This does not change everything. There are
only a few settings that this will change.

Please select your IMAP server:
bincimap = Binc IMAP server
courier = Courier IMAP server
cyrus = Cyrus IMAP server
dovecot = Dovecot Secure IMAP server
exchange = Microsoft Exchange IMAP server
hmailserver = hMailServer
macosx = Mac OS X Mailserver
mercury32 = Mercury/32
uw = University of Washington's IMAP server
gmail = IMAP access to Google mail (Gmail) accounts

quit = Do not change anything
Command >> <-- courier


SquirrelMail Configuration : Read: config.php
---------------------------------------------------------
While we have been building SquirrelMail, we have discovered some
preferences that work better with some servers that don't work so
well with others. If you select your IMAP server, this option will
set some pre-defined settings for that server.

Please note that you will still need to go through and make sure
everything is correct. This does not change everything. There are
only a few settings that this will change.

Please select your IMAP server:
bincimap = Binc IMAP server
courier = Courier IMAP server
cyrus = Cyrus IMAP server
dovecot = Dovecot Secure IMAP server
exchange = Microsoft Exchange IMAP server
hmailserver = hMailServer
macosx = Mac OS X Mailserver
mercury32 = Mercury/32
uw = University of Washington's IMAP server
gmail = IMAP access to Google mail (Gmail) accounts

quit = Do not change anything
Command >> courier

imap_server_type = courier
default_folder_prefix = INBOX.
trash_folder = Trash
sent_folder = Sent
draft_folder = Drafts
show_prefix_option = false
default_sub_of_inbox = false
show_contain_subfolders_option = false
optional_delimiter = .
delete_folder = true

Press any key to continue... <-- press ENTER


SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages

D. Set pre-defined settings for specific IMAP servers

C Turn color off
S Save data
Q Quit

Command >> <--S


SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages

D. Set pre-defined settings for specific IMAP servers

C Turn color off
S Save data
Q Quit

Command >> <--Q

One last thing we need to do is modify the file /etc/squirrelmail/config_local.php and comment out the $default_folder_prefix variable - if you don't do this, you will see the following error message in SquirrelMail after you've logged in: Query: CREATE "Sent" Reason Given: Invalid mailbox name.

vi /etc/squirrelmail/config_local.php

/**
* Local config overrides.
*
* You can override the config.php settings here.
* Don't do it unless you know what you're doing.
* Use standard PHP syntax, see config.php for examples.
*
* @copyright © 2002-2006 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: config_local.php,v 1.2 2006/07/11 03:33:47 wtogami Exp $
* @package squirrelmail
* @subpackage config
*/
//$default_folder_prefix = '';
?>


Now you can type in http://server1.example.com/webmail