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 system@mydomain.com

Step 1 : edit /etc/aliases file 

 

$ vi /etc/aliases

 

Add email ids at the bottom of the file.

 

root: system@mydmomain.com

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

root: system@mydomain.com, linux@mydomain.com

linux@mydomain.com 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
system@mydomain.com

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.

 extension=apc.so
 apc.enabled=1

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

 apc.ttl=72000
 apc.user_ttl=72000
 apc.gc_ttl=3600

Size of memory for apc ( 1024 M)

apc.shm_size=1024M

Enable apc stats.

apc.stat=1

Enable APC for command line php operations.

apc.enable_cli=1

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

apc.file_update_protection=2

Maximum size of single file that apc can store.

apc.max_file_size=1M

Maximum number of files APC can store ( rotation).

apc.num_files_hint=200000

Maximum number of users data entries that APC can store.

apc.user_entries_hint=20000

 

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 http://pecl.php.net/package/APC ( 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  http://domain.com/apc.php. 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:

apc1
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: 

APC INFO  luke.savvysme.com.au   128.199.188.56-s