CREATE TABLEnew_table LIKE original_table;
INSERT INTOnew_table SELECT * FROM original_table;
Category Archives: Hosting
redirect http to https
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [QSA,R=301,L]
lock_wait_timeout 31536000
mysql>
SET GLOBAL lock_wait_timeout = 600;
mysql kill specific users all running proccess
If your mysqldump or mysqlcheck stuck on some user database, you can try this:
mysql>
select concat('KILL ',id,';') from information_schema.processlist where user='some_username' into outfile '/tmp/mysql.txt';
source /tmp/mysql.txt;
cPanel account transfer on command line
Login your Old server SSH via root user and use these commands.
root@OLD[~]#cd /home
root@OLD[~]#/scripts/pkgacct
Once package account process completed, You can view backup file like cpmove-cpuser.tar.gz
Transfer account to another NEW server using RSYNC or SCP commands.
root@OLD[~]#rsync -avz –progress /home/cpmove-cpuser.tar.gz root@
User this command if your server have different SSH port.
root@OLD[~]#rsync –progress –stats -avz –rsh=’ssh -p5093′ cpmove-user.tar.gz root@
Once transfer completed goto NEW server SSH and restore account.
root@NEW[~]#/scripts/restorepkg oldcpuser
mysql dump all datbases to separate files
This is fast way to backup all MySQL database to separate files:
back_dir=/backups/databases/$(date +'%F')
mkdir -v -p $back_dir
mysql -s -e 'show databases' | egrep -v "information_schema|performance_schema" | while read db; do mysqldump -h localhost --single-transaction --events --ignore-table=mysql.event $db > $back_dir/$db.$(date +'%F').sql; [[ $? -eq 0 ]] && gzip $back_dir/$db.$(date +'%F').sql ; done
mysql import with custom character set
mysql -u username -p –default-character-set=latin1 database < backup.sql
php find and replace string
find . -iname ‘*php’ | xargs grep ‘search-string’ -sl | while read x; do echo $x; sed -i ‘s/search-string/replace-string/’ $x; done
directadmin empty messages list
cd /usr/local/directadmin/data/admin
echo -n “” > tickets.list
or the following for a User:
cd /usr/local/directadmin/data/users/username
echo -n “” > tickets.list
disable all file uploads to a server over HTTP
In your php.ini file set file_uploads=Off. This will disable all file uploads through HTTP.
-bash: htpasswd: command not found cPanel server
yum –disableexcludes=all install httpd-tools
mixed apache autorization – Allow from && Require valid-user
AuthName “Htaccess”
AuthUserFile /var/www/html/.htpasswd
AuthType Basic
Satisfy Any
Order Deny,Allow
Deny from all
Allow from 192.168.2.100
Require valid-user
[FATAL] munin_readconfig_part(datafile) – missing file
You are missing some munin tun time data in /var/lib/munin/
you need reinstall munin
munin-check
parsing apache logs to identify IP with max requests
gawk {‘print $1’} /var/log/httpd/access_log | sort -n | uniq -d -c | sort -n
cpanel parsing .html as php
vi .htaccess
RemoveHandler .html .htm
AddType application/x-httpd-php5 .html .htm