Thursday, January 21, 2010

How to Enable htaccess in Apache?

What is htaccess?
Htaccess files are files containing single or several configuration apache directives, which should be placed inside the web directory where changes have to made and all its sub directories.

The easient way to enable .htaccess file in apache is tp add the following in the Apache / HTTPD conf, Uncomment the below line and restart apache. You need to enable rewrite module

#LoadModule rewrite_module modules/mod_rewrite.so to

LoadModule rewrite_module modules/mod_rewrite.so

Add this to the Apache Main Configuration.
AccessFileName .htaccess
.htaccess file can have different name just specify the name following
AccessFileName your_htaccess_file_name

Pros
Useful when Administrators, Developers, requires to make configuration changes on per directory basis
Useful for ISP and Webhosting providers to permit multiple users running multiple sites on the same server to change thier own htaccess file.

Cons
Never use .htaccess files if you dont have the access to the Server Configuration File.
Uses Need to have root or Super User access to edit the main configuration file in apache.
Never Use user authetication in htaccess file instead do it in the Apache Main Configuration.
AllowOverride when set to allow apache will search for .htaccess file in every directory which would lead in poor performance of the webserver.

Directives in a .htaccess file

SSI (Server Side includes .htaccess file) Samples

Options +Includes
AddType text/html shtml
AddHandler server-parsed shtml


CGI Samples

Options +ExecCGI
AddHandler cgi-script cgi pl

Live Examples :


Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Satisfy all

Tuesday, January 12, 2010

Simple Steps to Send Mail Using Sendmail in Linux, Fedora, Centos, Ubuntu

Have you got your Linux distribution like Fedora, Centos, Redhat, Gentoo up and running?

Have you found issues sending mail from linux or send mail from command line?

Having Problem in Manageing Linux Sendmail Mail Server to send your First Mail?

Your Answer to all your Questions ends Here..

Follow the below step by step guide how to send mails from the default installation of Sendmail. No Sendmail Configuration required to be changed.

Sendmail is generally used as a Mail server for relaying all your mails for your Local Area Network and also used as Direct delivery. Sendmail is very powerful and can be build as a standalone Centralized High Avaliability Mail Server for a organization. It has the capability to stop SPAM Stop Virus mail with 1000's of Trick which can be best suited for your needs. As Sendmail is Open Source Free to Use, Develop and Distribute its the best choice for todays Linux System Administrator. The Sendmail Configuration is as easy as adding or removing a line from a word file "here You must have a bit of knowledge what is to be deleted or added", Today it comes default installed with majority of Linux distribution avaliable worldwide. And if you dont find it installed just google it THE BIG G "Referring Google" will give you precisely the exact rpm (linux executable program) for your distribution of linux.

Its popularty increased with the Integration of Sendmail Milters (Mail Filter which are Highly Customizab;e) which have really changed the Fucntionality of Mail Server Today

Step 1.
Check if Sendmail is Running for which execute the following command :
ps ax | grep sendmail
If you get the output something like this
1846 ? Ss 0:13 sendmail: accepting connections
1850 ? Ss 0:00 sendmail: Queue runner@00:15:00 for /var/spool/clientmqueue
1855 ? Ss 0:00 sendmail: Queue runner@00:15:00 for /var/spool/mqueue

Great Your Copy of Sendmail is Running
OR Type the command in the terminal
/etc/init.d/sendmail start
You can see Sendmail Starting
Starting sendmail: [ OK ]


Step 2.
Next Step is to check Sendmail Listening IP:port. Listening IP:Port is nothing but the IP address and port number on which sendmail has started and will accept mails other than which connection would be refused. To Check enter the following:
[root@techy ~]# netstat -tnlp | grep sendmail
If You Get the resultant as this
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 1846/sendmail: acce
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 1846/sendmail: acce


Hurray !!! Your sendmail is ready to accept connection on all the interfaces of your machine. Here “0.0.0.0:587” is Sendmail Mail Submission Port and “0.0.0.0:25” is used to Send mail to External SMTP Source. IF You Need to make sendmail listen on specific port you need to change the sendmail.mc and Build a new Sendmail.cf which we would cover in the Sendmail Configuration Part.

Sendmail.mc : It is the macrotized Version for sendmail configuration
Sendmail.cf : IT is read by Sendmail Deamon to perform task.

BY Default Sendmail Does not allow mails to be relayed to external sources. We need to make sendmail configuration to perform such tasks. In this example we’ll send mail to local user which is “root”

Step 3.
Now the Final Steps is to check if Mail are sent properly
We’ll use Telnet if you are not familiar with telnet don’t worry just copy the code and it will do the magic for you.
[root@techy ~]# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 techy.bounceme.net ESMTP Sendmail 8.14.3/8.14.3; Tue, 12 Jan 2010 23:29:14 +0530
mail from:support@linuxmaza.com
250 2.1.0 support@linuxmaza.com... Sender ok
rcpt to:root@localhost
250 2.1.5 root@localhost... Recipient ok
data
354 Enter mail, end with "." on a line by itself
subject: My First Test Mail Using Sendmail.

This is First Paragraph.
.
250 2.0.0 o0CHxEYV022243 Message accepted for delivery
quit
221 2.0.0 techy.bounceme.net closing connection


Once You receive the final Message accepted for delivery. Great Just remember the first part of the line “o0CHxEYV022243” which would be helpful during crisis or troubleshooting sendmail. Now it’s the time to check the mail We’ll use mutt to check the mail.
[root@techy ~]# mutt
And check the mail. IF you Did not receive the mail You need to troubleshoot the issue checking the logs. The default location to check the logs for sendmail is /var/log/maillog or /var/log/mail.
Command to check: Do you remember the “o0CHxEYV022243” which we asked you earlier just parse the logs using the same you would get the reason for non-delivery or success messages.

[root@techy ~]# cat /var/log/maillog | grep "o0CHxEYV022243"
Jan 12 23:29:29 techy sendmail[22243]: o0CHxEYV022243: Authentication-Warning: techy.bounceme.net: localhost [127.0.0.1] didn't use HELO protocol
Jan 12 23:30:22 techy sendmail[22243]: o0CHxEYV022243: from=support@linuxmaza.com, size=70, class=0, nrcpts=1, msgid=<201001121759.o0CHxEYV022243@techy.bounceme.net>, proto=SMTP, daemon=MTA, relay=localhost [127.0.0.1]




We would be adding some Sendmail Videos. Please let us Know how did you like the information provided above and any suggestions. Drop a Mail to admin@linuxmaza.com