Monday, September 27, 2010
How to set up SPF records
Friday, August 27, 2010
Patching the kernel
Thursday, July 22, 2010
apache/mysql optimization
------------------------
The apache directive KeepAlive specifies whether a connection has to be established dedicatedly for a request.
If you enable this directive using "on" , you must specify KeepAliveTimeout.The number of seconds Apache will wait for a subsequent request before closing the connection. Once a request has been received, the timeout value specified by the Timeout directive applies.
Setting KeepAliveTimeout to a high value may cause performance problems in heavily loaded servers. The higher the timeout, the more server processes will be kept occupied waiting on connections with idle clients.
This prevents unused connections from staying open for excessive amounts of time If you are going to leave KeepAlive on you will want to increase MaxKeepAliveRequests. Setting this higher allows more requests per connection and increases efficiency
#Another minor tweak that will give you a small performance boost as well as help reduce the effects of a DOS attack is changing the TimeOut Directive. This directive tells Apache how many seconds to wait while receiving an incoming request, processing it, and sending back a response.
HostnameLookups
This adds latency to every request because it requires a DNS lookup to complete before the request is finished. So it is always better to disable this directive.
MPM
Apache supports Multi-ProcessingModules (MPms). You can choose either Worker or Prefork. THe Prefork consumes higher memory than worker , it is quite famous for its speed of execution. So we normally enable Prefork for servers unless it is quite busy.
Below are the directives used in Prefork
MaxClients - sets a limit on the number of simultaneous connections/requests that will be served.Set this number too low and resources will go to waste. Set this number too high and an influx of connections will bring the server to a stand still. Set this number just right and your server will fully utilize the available resources.
An approximation of this number should be derived by dividing the amount of system memory (physical RAM) available by the maximum size of an apache/httpd process. The default value [ServerLimit 256] will work with 1-2GB of RAM.
Directive MaxRequestsPerChild is used to recycle processes. When this directive is set to 0, an unlimited amount of requests are allowed per process.
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxRequestsPerChild: maximum number of requests a server process serves
So a sample prefork configuration would look like this
StartServers 10
MinSpareServers 5
MaxSpareServers 10
MaxClients 225
MaxRequestsPerChild 4000
In the prefork model, a new process is created per request. Spare processes are kept idle to handle incoming requests, which reduces the start-up latency. The previous configuration starts 10 processes as soon as the Web server comes up and tries to keep between 5 and 10 idle servers running. The hard limit on processes is dictated by MaxClients. Even though a process can handle many consecutive requests, Apache kills off processes after 4,000 connections, which mitigates the risk of memory leaks.
The other apache configuration directives are as follows
Timeout 200
KeepAlive On
MaxKeepAliveRequests 200
KeepAliveTimeout 3
[mysqld]
skip-locking
max_connections=500 #The number of simultaneous clients allowed.
connect_timeout=15 #Number of seconds before timeout connection.
key_buffer = 128M #shared by all threads
key_buffer_size = 128M # key_buffer_size to at least a quarter, but no more than half, of the total amount of memory on the server
join_buffer_size = 3M #The size of the buffer that is used for full joins (joins that do not use indexes).
record_buffer = 1M # Each request doing a sequential scan over a table allocates a read buffer
max_allowed_packet = 16M #Max size of packet client can read from server.
table_cache = 3000 #Each time MySQL accesses a table, it places it in the cache. If the system accesses many tables, it is faster to have these in the cache. You should increase the table_cache if you have enough memory.
max_heap_table_size = 16M #This variable sets the maximum size to which MEMORY tables are allowed to grow.
tmp_table_size = 64M # The maximum size of internal in-memory temporary tables
sort_buffer_size = 4M # Each thread that needs to do a sort allocates a buffer of this size. Increase this value for faster ORDER BY or GROUP BY operations.
read_buffer_size = 2M #Each thread that does a sequential scan allocates a buffer of this size for each table it scans.
myisam_sort_buffer_size = 32M #The buffer that is allocated when sorting the index
query_cache_type=1
query_cache_limit=2M #The query_cache_limit (default 1MB) parameter sets the maximum result sets size stored in the query cache.
query_cache_size=64M # The memory allocated to store results from old queries.
max_user_connections = 25 # The maximum number of active connections for a single user .
max_connect_errors=10000 #If there is more than this number of interrupted connections from a host this host will be blocked from further connections.
safe-show-database
slow_query_log = 1
open_files_limit = 12000 #`open_files_limit' Number of files the system allows mysqld to open.
Tuesday, June 29, 2010
cPanel Error – error : Invalid maildirsize file!
Login to your server via SSH. The follow example applies where the email address is sharaf@domain.com, and the account username is “username”. Substitute the values in bold.
cd /home/username/mail/domain.com/sharaf/
rm -f maildirsize
Tuesday, June 8, 2010
Customize Apache default Success page
Navigate to /usr/local/apache/htdocs
cd /usr/local/apache/htdocs
And finaly edit the file index.html
nano index.html
If you list the content of /usr/local/apache/htdocs you will see that you can also modify the content of other error pages that cpanel’s apache outputs.
Friday, June 4, 2010
MySQL ERROR! Couldn't find MySQL manager (/var/lib/bin/mysqlmanager)
/etc/init.d/mysql status
ERROR! MySQL is not running
[root@ns2 subsys]# /etc/init.d/mysql restart
ERROR! MySQL manager or server PID file could not be found!
Starting MySQL ERROR! Couldn't find MySQL manager (/var/lib/bin/mysqlmanager) or server (/var/lib/bin/mysqld_safe)
[root@ns2 subsys]# /etc/init.d/mysql stop
ERROR! MySQL manager or server PID file could not be found!
check in /etc/my.cnf ----------whether base_dir is set to /var/lib if so remove it.
Friday, May 28, 2010
Increase max emails per hour for a single domain in cPanel
You can change the maximum number of emails allowed for a particular domain to a different number than the system default using the file (Other than WHM settings)
/var/cpanel/maxemails
Just add an entry like “domain.com = 100″ . Now 100 is the maximum email per hour limit for domain.com.
But please make sure that you have executed the following script after updating the file /var/cpanel/maxemails.
#/scripts/build_maxemails_config