Monday, June 2, 2014

Postfix - Change Sender's email address from root

When you send mail using Postfix through command line or similar way, it shows sender's e-mail address root@domain-name. You do not want this and you want your defined email should be visible in recipient's mailbox. Follow the steps.

Add following line in the file /etc/postfix/main.cf 
smtp_generic_maps = hash:/etc/postfix/generic
Now edit the file /etc/postfix/generic, if it is not there, create it.
Add your 'from address' and 'the address you want to be seen in place of from address' in this file.
Example :
root@domain.com linuxamination@gmail.com
user1@domain.com linuxamination@gmail.com
You can define different mail addresses for each user of Linux. 
Now Run following commands in terminal.
postmap /etc/postfix/generic
and
service postfix restart
Now it displays linuxamination@gmail.com as sender, when I send mail as a root or user1.
echo "content-of-the-mail" | mail -s "subject-of-the-mail" "recipient@mail-address.com" 

Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable ERROR: `phpize' failed

Install autoconf on your Linux system.

If you are using Debian or Ubuntu, Run
sudo apt-get install autoconf
If you are using CentOS or RHEL or fedora, Run 
sudo yum install autoconf

httpd dead but pid file exists

Your Apache is not working because it gives following error :
httpd dead but pid file exists

You have tried to restart Apache several times but still it gives same error.
To remove this error, you need to remove Semaphore Arrays of Apache.

Find all Semaphore Arrays of Apache. Run following command in terminal.
ipcs -s | grep apache
Now remove each entry using command
ipcrm -s semid
semid is second column of the table.

If there are multiple entries of Apache and it is difficult to remove each entry individually, Run following command.
for i in `ipcs -s | grep apache | awk '{ print $2 }'` ; do ipcrm -s $i ; done;
If it is not working for you, Run
ipcs -s | grep apache |  perl -e 'while (<STDIN>) { @a=split(/\s+/); print `ipcrm sem $a[1]`}'
Now restart Apache. Run following command.
service httpd restart 

Solution : 2
If still you are facing same error after restarting Apache. Run
rm /var/lock/subsys/httpd
and Run
rm /var/run/httpd/httpd.pid
Now restart Apache again.
service httpd restart 
Now what is Semaphore Array
A semaphore is a variable or abstract data type that is used for controlling access, by multiple processes.
In its simplest form a semaphore is a location in memory whose value can be tested and set by more than one process. 
ipcs  provides  information on the ipc facilities for which the calling process has read access.
-s displays semaphore arrays.
ipcrm removes a message queue, semaphore set or shared memory id.