How to change default root@ email address linux / postfix / centos?

Change root@hostname to different email address


By default, any email sent by system is sent to root@hostname. So critical server errors, log errors, corn jobs alerts e.t.c all are sent to this default email address. To change it to different appropriate email id, we can do this by two ways.


By updating email aliases file:

For this example, lets set email to

Step 1 : edit /etc/aliases file 


$ vi /etc/aliases


Add email ids at the bottom of the file.



To add multiple email ids, we can simply separate them by comma.

root:, is second email id 


Step 2: Run the aliases command, to compile aliases file. 

$ newaliases

Step 3: Restart postfix server.

service postfix restart


Second way:

We can simply create .forward file to the folder root and add email address there.

$ vi /root/.forward

Restart postfix server
$ service postfix restart.


That’s it. Enjoy!


How to install APC in centos for PHP better performance ( opcode)

APC for PHP better performance:

APC is a op-code caching for PHP. Once PHP code is run, APC caches the complied PHP code so for next time, time for compiling PHP will be reduce and gives faster performance.  APC caches files in memory so  performance of PHP code improves significantly.

Installing APC:

Make sure PHP is installed first 🙂 . we need to install few pre-requist for PHP.

$ yum install php-pear php-devel httpd-devel pcre-devel gcc make

$ pecl install apc

Configuring APC:

Open APC config file and make sure you have atlest following configuration:

vi /etc/php.d/apc.ini

Enable APC for php.

The number of seconds a cache entry is allowed to idle in a slot before APC dumps the cache.


Size of memory for apc ( 1024 M)


Enable apc stats.


Enable APC for command line php operations.


Allow 2 seconds after a file is created before it is cached. This will prevent premature PHP pages to get cached.


Maximum size of single file that apc can store.


Maximum number of files APC can store ( rotation).


Maximum number of users data entries that APC can store.



You can put your configuration in php.ini file but i prefer to have separate file like above for configuration. Values mentioned above are for demonstration purpose, different values  for APC can be set  which depends on number of PHP pages, size of memory in server, number of page hits e.t.c

Restart httpd server:

service httpd restart


APC installation comes with apc.php file, which can be use to monitor APC performance. This file can be found inside APC package  OR can be download from ( unzip and look for apc.php file).

Once apc.php is downloaded copy it to your domain so that you can assess it.

Now from browser, you can go to I prefer to wait for a day to see the APC performance so we can have clear idea how well our configuration did.


Sample output of APC:

Here, we clearly see that APC is not performing very well as we have 44% misses. To optimize this we can reduce the memory and also we can increase max_file_size and also TTL time so that more can be cached in APC.  Normally when missed rate is more than 10% ,  its better to reconfigure the settings of APC.

Well tuned APC will look like below: