Posts

XML Parsing Error

Sometimes you get the following error message on your website: XML Parsing Error: not well-formed Location: http://yourdomain.com/ Line Number 17, Column 24: <img src="img/img.gif"alt=""/> "XML Parsing Error" usually occurs when something is trying to read the XML, not when it is being generated. Also, "not well-formed" usually refers to errors in the structure of the document, such as a missing end-tag, not the characters it contains. Also, the error occur due to using of Unicode Character ”( RIGHT DOUBLE QUOTATION MARK ) instead of " (Unicode Character 'QUOTATION MARK) in your codes. Sometimes, this error comes due to the plugin which is used for the RSS feed or the code issue related to RSS feed. Your feed is not well formed according to the XML specification . All feeds must be well-formed XML.  There are several basic approaches to solving this: escaping problematic characters ( < becomes &lt; ...

spamd failed

If you get the following error: -------- spamd failed @ Sat Jul 25 16:39:14 2015. A restart was attempted automagically. Service Check Method:  [check command] Cmd Service Check Raw Output: Spamd is not running -------- Fix: You can follow the below mentioned steps to avoid that: ------- 1. Deleted the old file '/var/run/chkservd/spamd'. 2. Restarted  chkservd service. 3. Run the script /scripts/fixspamassassinfailedupdate. ------- Monitor the logs /var/log/chkservd.log . grep for "Restarting spamd". If you cannot find any such details that means the spamd is running fine now without sending any failure notices.

How to upgrade/downgrade MySQL version in cPanel server

You can easily change the major version of MySQL running on your server through WHM, keeping in mind that the actual version will be dependent on what cPanel has released in their repository. WHM >> Software >> MySQL Upgrade >> Select between "MySQL 5.1" or "MySQL 5.5" To change the MySQL version below 5.1, edit the file /var/cpanel/cpanel.config and look for this line: mysql-version=5.1 Then change the version number to the major version that you want to downgrade to. For instance, 4.0, 4.1 or 5.0. Then save the file and run the following script: # /scripts/mysqlup --force Now re-run apache build (easyapache) script so it can build php-mysql connector: # /scripts/easyapache  The method described would be performed at one's own risk. A manual downgrade is not recommended and can incur significant risk when attempted on an existing system. A full backup of the MySQL data directory is advised, and for a proper downgrade one sh...

cPanel changes through shell commands

Contact Information & Preferences Change the email address inside of cPanel for alert emails. # grep CONTACT /var/cpanel/users/username Modify the above lines in the users file and run: /scripts/updateuserdomains Email Notification settings Modify the below lines to affect emails being sent on quota hits. # grep notify /home/username/.cpanel/contactinfo Change Style # grep RS /var/cpanel/users/username Change the above line and run /scripts/updateuserdomains Change Language # grep LANG /var/cpanel/users/username Change the above line to the language of choice and run /scripts/updateuserdomains Change Owner # grep OWNER /var/cpanel/users/username Owner should be set to root for a shared account or the reseller user for a reseller/resold account. Run /scripts/updateuserdomains after making any changes to the owner. Email Accounts List all Email accounts. # user=ausisdha; gawk -F":" '{ print $6 }' /home/$...

strace command

strace can be seen as a useful diagnostic and instructional debugger. It allows a programmer/user to quickly find out how a program is interacting with the OS. It does this by monitoring system calls and signals. Syntax: strace -tf -s 1000 <command> The above syntax include timestamps, follow forks, increase string size to 1000 characters. You can reduce the set of calls returned to just those dealing with network, file access, reads, and writes as follows: strace -tf -s 1000 -e trace=file,network,write,read <command> Reading strace output: Each line in the output represents a system call. They follow the format: system_call(argument1, argument2, ... ) = return_value execve - the arguments show the path to the command being run followed by a list of arguments (the command itself is argument 0) brk - the process requests memory access - check to see if the file is able to be read and/or written to open - open the file specified read - read the conten...

DNS Errors

1. rndc: connect failed: 127.0.0.1#953: connection refused This error may appear on Centos 6.3+ when named is unable to bind to port 953 for rndc. This is caused by the named init script not being configured properly for "portreserve" and can be fixed using the following steps: # mv -v /etc/init.d/named /etc/init.d/named.prfixbak # yum -y reinstall bind # service named stop # service portreserve restart # service named start 2. Using named-checkzone to check for errors named-checkzone will check a given DNS zone for errors. # named-checkzone avinash.com /var/named/avinash.com.db 3. Flush local DNS cache The local DNS cache can be flushed, thereby forcing an actual domain name lookup. You can do it using following steps: In Linux : Open up a root terminal window (ctrl T in gnome). Type the following command and hit enter. # /etc/init.d/nscd restart Restart your application (e.g. browser or email). In Windows: Run the following on command promp...

SQL Injection

What is SQL Injection SQL injection refers to the act of someone inserting a MySQL statement to be run on your database without your knowledge. Injection usually occurs when you ask a user for input, like their name, and instead of a name they give you a MySQL statement that you will unknowingly run on your database. SQL Injection Example: Below is a sample string that has been gathered from a normal user and a bad user trying to use SQL Injection. We asked the users for their login, which will be used to run a SELECT statement to get their information. MySQL & PHP Code: // a good user's name $name = "avi";  $query = "SELECT * FROM customers WHERE username = '$name'"; echo "Normal: " . $query . "<br />"; // user input that uses SQL Injection $name_bad = "' OR 1'";  // our MySQL query builder, however, not a very safe one $query_bad = "SELECT * FROM customers WHERE username = ...

How to configure Master Slave replication in MySQL

Replication enables data from one MySQL server, called the master to be replicated to one or more MySQL servers, called slaves. MySQL database replication is used to spread the load among multiple slaves to improve performance. MySQL allows slave nodes to have read access on the replicated databases. This means, that you can load balance the requests so that the master will handle the write requests while the slave(s) will manage the reading. I suppose MySQL is already installed in the Master as well as slave server. Now, follow the steps to configure Master Slave replication: Master server Setup: 1. Login to the MySQL shell and create a new user for replication using following queries: [root@master-node~] # mysql mysql> GRANT REPLICATION SLAVE ON *.* to 'replication_user'@'%' IDENTIFIED BY 'repl_password'; mysql> FLUSH PRIVILEGES; mysql> quit; 2. Dump the data from the Master server and copy it to the Slave server using mysqldump: [ro...

SSH keys

SSH Keying through Linux, Mac OS X SSH keys are fairly simple to setup and can be done so even simpler when using a native terminal application, such as the terminal in OSX. Here's how! In terminal, type the following command: ssh-keygen -t dsa This will ask you a few questions, the defaults for which are just fine, no passcode is necessary. This will generate a key in the ~/.ssh/ directory. Now we just need to get that file up to the server. You can do this using scp or rsync, I'll give rsync as an example here. rsync -av -e "ssh" ~/.ssh/id_dsa.pub root@IP_address:.ssh/authorized_keys In the event your server uses a non-standard port for ssh, you can specify this inside the quotes around ssh, an example for port 2222 is below. rsync -av -e "ssh -p 2222" ~/.ssh/id_dsa.pub root@ip.add.ress.here:.ssh/authorized_keys Once running this command you will be prompted for your root password as rsync creates an SSH connection to tra...

Merge two MySQL databases

To copy data from a table to another table in two MySQL databases, both the databases need to exist on the same account. Method 1: Using Cpanel From cPanel, click on phpMyAdmin icon. Click on the SQL tab at the top. You will see where it says, 'Run SQL query/queries on server "localhost":' In the text box below that, insert the following code, but replace DB1 and DB2 with the database names. Also, replace TABLE1 with the table name you are trying to merge. INSERT INTO DB1.TABLE1 SELECT * FROM DB2.TABLE1 Click on Go button. Repeat for any other tables you want to merge. Method 2. Through Shell (SSH) From SSH, you need to type the command to access mysql. Here is the format, but replace MYNAME with your username and PASS with your password. mysql -u MYNAME -pPASS Now type the following code, but replace DB1 and DB2 with the database names. Also, replace TABLE1 with the table name you are trying to merge. INSERT IN...