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
Thursday, May 20, 2010
OpenVZ network down SIOCADDRT: Network is unreachable
/etc/sysconfig/network-scripts/ifup-routes venet0:0
Sunday, May 9, 2010
open3: fork failed: Cannot allocate memory at cpsrvd-ssl line 6152
Sunday, May 2, 2010
Wednesday, April 21, 2010
LNMP – A tool to auto-compile & install & manage Nginx+MySQL+PHP on Linux
The current version : 0.3 ,Now support Linux distribution : CentOS 4.8~5.4 32/64bit, Debian 4.0~5.0 32bit/64bit ,Ubuntu.
The programme installed in LNMP:
Nginx:0.7.63
PHP:5.2.10
MySQL:5.1.35
Zend Optimizer:3.3.9
eaccelerator:0.9.5.3
Installation Guide:
wget -c http://soft.vpser.net/lnmp/lnmp0.4-full.tar.gz
1.Install on CentOS
First Download lnmp ,Run the command : wget http://soft.vpser.net/lnmp/lnmp0.3.tar.gz , Then decompress lnmp0.3.tar.gz Run the command : tar zxvf lnmp0.3.tar.gz
Run the command : cd lnmp0.3
Run ./centos.sh then enter the domain name, press Enter key twice. The programme will auto-complie and install Nginx,MySQL,PHP,Zend Optimizer.
2.Install on Debian
First Download lnmp ,Run the command : wget http://soft.vpser.net/lnmp/lnmp0.3.tar.gz , Then decompress lnmp0.3.tar.gz Run the command : tar zxvf lnmp0.3.tar.gz
Run the command : cd lnmp0.3
If you Debian is 32bit please run ./debian.sh else run ./debian64bit.sh. then enter the domain name, press Enter key twice. The programme will auto-complie and install Nginx,MySQL,PHP,Zend Optimizer.
3.Install eaccelerator
If you want to use eaccelerator please run ./eaccelerator.sh the programme will auto-compile and install.
4.VirtualHost Management
1). Add VirtualHost: run ./vhost.sh Prompted to enter the domain name you want to binding, press Enter key, and then enter the directory to be bound (absolute directory, such as /home/wwwroot/lnmp).
2). More feature under development.
Friday, April 2, 2010
Cpanel disk used incorrect showing unlimited or 0MB
is this doesn't work and you are using Virtuozzo or OpenVZ you will need to set the QUOTAUGIDLIMIT perimeter - this allows the system to allocate user IDs (UID)
e.g (openvz)
vzctl set 101 --quotaugidlimit 1000 --save
then run the scrip "/scripts/fixquotas"
and it should all work.
Troubleshooting
If you've done the above and it still doesn't work (or the value still says 0MB) this may be due to cPanel caching the disk usage results. to disable this:
Select the following in your WHM.
WHM >> Tweak Settings >> System >> "Disable Disk Quota display caching (WHM will cache disk usage which may result in the display of disk quotas being up to 15 minutes behind the actual disk usage. Disabling this may result in a large performance degradation.)"
Mysql Database showing 0MB disk usage
vi /var/cpanel/cpanel.config
find "disk_usage_include_sqldbs"
change the value from 0 to 1
and run
#
/scripts/update_db_cache
Issue should be fixed :)
Saturday, March 6, 2010
Wednesday, February 17, 2010
Error "psa dead but subsys locked" is shown when check status of Parallels Plesk Panel from the command line
Error "psa dead but subsys locked" is shown when check status of Parallels Plesk Panel from the command line
~# /etc/init.d/psa status
psa dead but subsys locked
~#
What does the error mean?
Cause
The error means that Parallels Plesk Panel is stopped but lock file exists.Another way to check status of Parallels Plesk Panel is using command "netstat". Here is an example of correct output if Parallels Plesk Panel was running:
Parallels Plesk Panel version 7.x, 8.x
~# netstat -antp | grep 8443
tcp 0 0 0.0.0.0:8443 0.0.0.0:* LISTEN 9691/httpsd
~#
Parallels Plesk Panel version 9.x
~# netstat -antp | grep 8443
tcp 0 0 0.0.0.0:8443 0.0.0.0:* LISTEN 21856/sw-cp-serverd
~#
Here is result if Parallels Pleks Panel is not running:
~# netstat -antp | grep 8443
~#
Lock file of Parallels Plesk Panel on RedHat-like operating systems is /var/lock/subsys/psa.
Resolution
Remove file /var/lock/subsys/psa manually and start the service usual way:~# rm -f /var/lock/subsys/psa
~# /etc/init.d/psa start1
Starting Plesk... done
~#
NOTE: Option "start1" allows to start only Parallels Panel Panel without other services.
Error log file is /usr/local/psa/admin/logs/httpsd_error_log for Parallels Plesk Panel version 7.x, 8.5 or /var/log/sw-cp-server/error_log for Parallels Plesk Panel version 9.x.
Monday, February 1, 2010
sysctl hardening
Securing Your Server
How to install wordpress!
Thursday, January 14, 2010
Howto: enable TUN module on a VPS
TUN module is required to configure VPN tunneling and to configure VPN on a VPS, you need to enable the module from the Hardware node. Login to your Host server and execute the following command:
First check if the TUN module is enabled on the hardware node:
lsmod | grep tun
If not, load the module using modprobe:
modprobe tun
Now, enable the TUN module on a VPS:
vzctl set VEID devices c:10:200:rw save
vzctl exec VEID mkdir -p /dev/net
vzctl exec VEID mknod /dev/net/tun c 10 200
vzctl exec VEID chmod 600 /dev/net/tun
where, VEID is the VPS ID you want to enable the TUN module on.
Wednesday, January 13, 2010
Fantastico shows error 'You cannot install more than one script in the root directory of a domain'
2. Go to "file manager"
3. click on the ".fantasticodata" folder
4. open up "installed_in_root.php" and edit it.
This is an example of what I mean:
If you open up "installed_in_root.php" you will see something like this:
$installed_in_root["domain.com"] = 1;
This is what you need to delete.
(this is just an example from my "installed_in_root,php" file).
Keep in mind that every install of wordpress you have made will be stored in this file, be very carefull not to delete any of your other wordpress sites out of it.
I hope this makes sense lol, I'm not very good at explaining things.
Change Time Zone for a particular account on cpanel server
SetEnv TZ
e.g. SetEnv TZ Australia/Adelaide
php_value date.timezone "Australia/Adelaide"