dapurhosting.com Blog for Tech

March 22, 2012

Drop memory cache

Filed under: Server — dh @ 11:06 am

drop memory cache


crontab -e
*/15 * * * * sync; echo 3 > /proc/sys/vm/drop_caches

March 16, 2012

Nginx

Filed under: Apache,Server — dh @ 8:47 am

Install NGINX

cd /usr/local/src
wget http://nginxcp.com/latest/nginxadmin.tar
tar xf nginxadmin.tar
cd publicnginx
./nginxinstaller install

Uninstall NGINX

cd /usr/local/src
wget http://nginxcp.com/latest/nginxadmin.tar
tar xf nginxadmin.tar
cd publicnginx
./nginxinstaller uninstall

Nginx Installation error:

File "/scripts/createvhosts.py", line 2, in ?
First uninstall nginx then run this command
wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz
tar fxz Python-2.5.2.tgz
cd Python-2.5.2
./configure
make
make install

Nginx running warning

nginx: [warn] conflicting server name "YOURIPADDRESS" on 66.228.117.248:80, ignored
nginx: [warn] conflicting server name "YOURIPADDRESS" on 66.228.117.248:80, ignored
nginx: [warn] conflicting server name "YOURIPADDRESS" on 66.228.117.248:80, ignored

nginx: [emerg] bind() to YOURIPADDRESS:80 failed (98: Address already in use)
nginx: [emerg] bind() to YOURIPADDRESS:80 failed (98: Address already in use)
nginx: [emerg] bind() to YOURIPADDRESS:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
already running.

run this commands
cd /etc/nginx/vhosts
perl -pi -w -e 's/server_name(.*) YOURIPADDRESS/server_name$1/g;' *

Replace YOURIPADDRESS with the ip address you see in the errors.

Now go to WHM > Tweak settings and change Apache non-SSL IP/port to 0.0.0.0:8081

March 14, 2012

How to disable comments in Drupal

Filed under: CMS — dh @ 3:02 am

If you have admin access to Drupal log in and go to Administer – Content – Content Types. Then edit the content type of your choice and make sure comments are set to off by default.

Alternatively the above can be done directly by executing the following query in your database:

UPDATE system SET status = '0' WHERE filename = 'modules/comment/comment.module';

When you decide to re-enable the module simply issue the reverse query:

UPDATE system SET status = '1' WHERE filename = 'modules/comment/comment.module';

Disable User Registration

UPDATE variable SET 'value' = 's:1:”0?;'  WHERE 'name' = 'user_register'; 

March 3, 2012

Unable to fetch the cPanel user file

Filed under: cPanel/WHM — dh @ 3:44 am

log into root SSH on the machine and do the following:

cd /var/cpanel/users
ls -lah username
cat username

permission must:
rw-r----- 1 root username 596 Jun 8 14:03 username

Inside the file, the USER=username entry should have the username of that user. Some 3rd party plugins modify the username by appending .sometext to the end of the username. This can cause cPanel to be unable to read the user’s file.

February 11, 2012

MySQL slow queries

Filed under: MySql — dh @ 7:57 am

1. Activate the logging of mysql slow queries.

mysqladmin var |grep log_slow_queries
| log_slow_queries | OFF |

If log_slow_queries is ON then we already have it enabled. This setting is by default disabled – meaning that if you don’t have log_slow_queries defined in the mysql server config this will be disabled.
The mysql variable long_query_time (default 1) defines what is considered as a slow query. In the default case, any query that takes more than 1 second will be considered a slow query.

Ok, now for the scope of this article we will enable the mysql slow query log. In order to do to do this in your mysql server config file (/etc/my.cnf RHEL/Centos or /etc/mysql/my.cnf on Debian, etc.) in the mysqld section we will add:

[mysqld]
long_query_time = 1
log-slow-queries = /var/log/mysql/mysql-slow.log

This configuration will log all queries that take more than 1 sec in the file /var/log/mysql/mysql-slow.log. You will probably want to define these based on your particular setup (maybe you will want the logs in a different location and/or you will consider a higher value than 1 sec to be slow query).

Once you have done the proper configurations to enable mysql to log slow queries you will have to reload the mysql service in order to activate the changes.
2. Investigate the mysql slow queries log.

After we enabled slow query logging we can look inside the log file for each slow query that was executed by the server. Various details are logged to help us understand how was the query executed:

Time: how long it took to execute the query
Lock: how long was a lock required
Rows: how many rows were investigated by the query (this can help see quickly queries without indexes)
Host: the actual host that launched the query (this can be localhost, or a different one in multiple servers setup)
The actual mysql query.

This information allows us to see what queries need to be optimized, but on a high traffic server and with lots of slow queries this log can grow up very fast making it very difficult to find any relevant information inside it.
In this case we have two choices:

We increase the long_query_time and we focus on the queries that take the most time to complete, and we gradually decrease this once we solve the queries.
We use some sort of tool to parse the slow query log file and have it show us the most used queries.

February 2, 2012

httpd.conf permanent change on cpanel

Filed under: Apache — Tags: , — dh @ 3:58 am

jalankan command ini supaya httpd.conf yang baru diganti menjadi default apache (konfigurasi tidak hilang)

/usr/local/cpanel/bin/apache_conf_distiller –update

January 20, 2012

Speed Up Software Raid Resync And Building

Filed under: Server — Tags: , — dh @ 5:53 am

Check speed and time required to finish sync
cat /proc/mdstat

echo value > /proc/sys/dev/raid/speed_limit_min

OR

sysctl -w dev.raid.speed_limit_min=value

Check speed and time required again to see the perfomance

cat /proc/mdstat

January 14, 2012

Disable wp-cron.php

Filed under: Worpress — dh @ 4:26 am

Disable wp-cron.php

add this to wp-config.php
define('DISABLE_WP_CRON', true);

comment this line on public_html/wp-includes/Cron.php
//spawn_cron( $local_time );

add this to user cron job

php -q /home/cPanel_User/public_html/wp-cron.php > /dev/null 2>&1

January 9, 2012

Linux Malware Detect

Filed under: Securtiy,Server — dh @ 4:39 am

source:

  • http://www.rfxn.com/projects/linux-malware-detect/
  • http://www.webhostingtalk.com/wiki/Linux_Malware_Detect

Installation


wget http://www.rfxn.com/downloads/maldetect-current.tar.gz
tar xfz maldetect-current.tar.gz
cd maldetect-*
./install.sh

Configure Linux Malware Detect


vi /usr/local/maldetect/conf.maldet

Manual Scan


maldet --scan-all /home?/?/public_html

Cron Job

vi /etc/cron.daily/maldet

January 5, 2012

Exim, refused: too many connections

Filed under: Server — Tags: , — dh @ 2:39 pm

2012-01-05 08:11:18 Connection from [x.x.x.x] refused: too many connections
2012-01-05 08:11:18 Connection from [x.x.x.x] refused: too many connections
2012-01-05 08:11:18 Connection from [x.x.x.x] refused: too many connections
2012-01-05 08:11:18 Connection from [x.x.x.x] refused: too many connections
2012-01-05 08:11:18 Connection from [x.x.x.x] refused: too many connections
2012-01-05 08:11:18 Connection from [x.x.x.x] refused: too many connections
2012-01-05 08:11:18 Connection from [x.x.x.x] refused: too many connections

Edit /etc/exim.conf

smtp_accept_max = nn
smtp_accept_max_per_host = nn

restart exim /etc/init.d/exim restart

« Newer PostsOlder Posts »

Powered by WordPress