RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]
Monthly Archives: February 2014
redirecting non-www to www with .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
rebuild a corrupted rpm database
rm -f /var/lib/rpm/__db*
rpm -vv –rebuilddb
yum update
yum: There Are Unfinished Transactions Remaining
yum install yum-utils
yum-complete-transaction –help
LibClamAV Error: cli_writen: write error: No space left on device
It means your /tmp have not enough disk space.
dynamic DNS on AWS
yum-config-manager –enable epel
yum install -y noip
noip2 -C
chkconfig noip on
service noip start
linux – change shell prompt without affecting the real hostname
echo “export SRVNAME=linux_server” > /etc/profile.d/bash-prompt
#Edit bashrc file to change PS1:
vi /etc/bashrc >>
shopt -s checkwinsize
[ “$PS1” = “\\s-\\v\\\$ ” ] && PS1=”[\u@$SRVNAME \W]\\$ ”
#Change shell title:
vi /etc/sysconfig/bash-prompt >>
echo -ne “\033]0;${USER}@${SRVNAME}:${PWD/#$HOME/~}\007”
chmod +x /etc/sysconfig/bash-prompt
wordpress – Notice: Undefined Index and Cannot modify header
It occurs when WP_DEBUG is enabled:
The WP_DEBUG option, added in WordPress, controls the reporting of some errors and warnings and enables use of the WP_DEBUG_DISPLAY and WP_DEBUG_LOG settings. The default value is false.
NOTE: The true and false values in the example are not set in apostrophes (‘) because they are boolean values.
define( ‘WP_DEBUG’, true );
define( ‘WP_DEBUG’, false );
Additionally, if you are planning on modifying some of WordPress’ built-in JavaScript or Cascading Style Sheets, you should add the following code to your config file:
define( ‘SCRIPT_DEBUG’, true );
Then the uncompressed versions of scripts and stylesheets in wp-includes/js, wp-includes/css, wp-admin/js, and wp-admin/css will be loaded instead of the .min.css and .min.js versions.
php exec vs shell_exec
exec — Execute an external program
system — Execute an external program and display the output
shell_exec — Execute command via shell and return the complete output as a string
linux scan virus with clamav
update clamav virus database:
freshclam
scan for virus:
clamscan -ir /home/username/public_html
mysql – Host ‘host_name’ is blocked
By default, mysqld blocks a host after 10 connection errors. You can adjust the value by setting max_connect_errors at server startup:
shell> mysqld_safe –max_connect_errors=10000 &
The value can also be set at runtime:
mysql> SET GLOBAL max_connect_errors=10000;
If you get the Host ‘host_name’ is blocked error message for a given host, you should first verify that there is nothing wrong with TCP/IP connections from that host. If you are having network problems, it does you no good to increase the value of the max_connect_errors variable.
switch postfix with exim or exim with postfix
alternatives –config mta
debugging exim MTA
killall exim
exim -v -bd
Also always useful:
exim -bt
exim -bt
or verbose mail sessions:
exim -v -odf
forwarding mail exim
yum install exim
mkdir /etc/exim/vhosts
vi /etc/exim/vhosts/linuxėyou.tk >>
info: [email protected]
vi /etc/exim/vhosts/linuxėyou.com >>
info: [email protected]
#Add virtual hosts
vi /etc/exim.conf >
domainlist local_domains = @ : localhost : localhost.localdomain : dsearch;/etc/exim/vhosts
#Create new router:
vi /etc/exim.conf >
virtual:
driver = redirect
domains = dsearch;/etc/exim/vhosts
data = ${lookup{$local_part}lsearch{/etc/exim/vhosts/$domain}}
no_more
service exim restart
postfix change outgoing IP address
vi /etc/postfix/master.cf
smtp unix – – – – – smtp
-o smtp_bind_address=xx.xx.xx.xx
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay unix – – – – – smtp
-o smtp_bind_address=xx.xx.xx.xx
-o smtp_fallback_relay=