dapurhosting.com Blog for Tech

March 26, 2012

Disable PHP Execition

Filed under: Apache — dh @ 6:03 am

open .htaccess and add


Order Deny,Allow
Deny from all

March 23, 2012

Tuning MySQL Performance with MySQLTuner

Filed under: MySql — Tags: , , — dh @ 8:56 am

You can download the MySQLTuner script as follows:

wget http://mysqltuner.com/mysqltuner.pl

In order to run it, we must make it executable:

chmod +x mysqltuner.pl

Afterwards, we can run it. You need your MySQL root password for it:

./mysqltuner.pl

MySql Configuration

Filed under: MySql — dh @ 8:40 am

[mysqld]
safe-show-database
skip-locking

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
skip-networking

##used in replication to give each master and slave a unique identity
server-id=1

##amount of seconds during inactivity that MySQL will wait before it will close a connection on a non-interactive connection.
wait_timeout=5

##amount of seconds during inactivity that MySQL will wait before it will close a connection on interactive connection, interactive is mysql shell sessions
interactive_timeout=28800

##The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake
connect_timeout=5

##If more than this many successive connection requests from a host are interrupted without a successful connection, the server blocks that host from further connections
max_connect_errors=10

#The maximum number of simultaneous connections permitted to any given MySQL user account
max_user_connections=15

##This value indicates how many maximum concurrent connections mysql server can handle. If mysql reaches to it maximum (max) limit then you can see errors like "too many connections".
max_connections=200

##key_buffer_size is the size of the buffer used for index blocks. The key buffer is also known as the key cache.
key_buffer_size=128M

#The minimum size of the buffer that is used for plain index scans, range index scans, and joins that do not use indexes and thus perform full table scans.
join_buffer_size=1M

##Each session that needs to do a sort allocates a buffer of this size
sort_buffer_size=2M

##Each thread that does a sequential scan allocates a buffer of this size (in bytes) for each table it scans.
read_buffer_size=131072

#The maximum size of one packet or any generated/intermediate string.
max_allowed_packet=2M

##The number of open tables for all threads
table_open_cache=2048

##which sets the number of threads to hold open in memory to service new connections
thread_cache_size=16

##enables applications to give the threads system a hint about the desired number of threads that should be run at the same time.
thread_concurrency=10

##Cache all cacheable query results except for those that begin with SELECT SQL_NO_CACHE.
query_cache_type=1

##Do not cache results that are larger than this number of bytes
query_cache_limit=1M

##The amount of memory allocated for caching query results
query_cache_size=128M

##The number of open tables for all threads
table_cache=5120

tmp_table_size=32M
max_heap_table_size=64M

innodb_buffer_pool_size=64M
innodb_additional_mem_pool_size=8M
innodb_log_file_size=8M

##If a query takes longer than this many seconds, the server increments the Slow_queries status variable
long_query_time=1

##to enable or disable the slow query log
slow_query_log=1
slow-query-log=1
slow_query_log_file=/var/log/mysql/mysql-slow.log

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.

Powered by WordPress