Wednesday 27 July 2011

Clamscan Script

Often with a compromised web server it’s always nice to set the infected files to be immutable.   Here’s my way of doing things.

Starting with an install of clamAV and running an update
yum install clamscan -y

freshclam

Scan to file and send to background
clamscan /var/www/vhosts/ -r > ~/clamscan &

Search for infected files (FOUND) and set them to be immutable
 chmod 000 `grep FOUND ~/clamscan.20130319 | awk ‘{print $1}’ | cut -d: -f1`

Saturday 9 July 2011

how to Enable wildcard subdomains

When you install WPMU by default the subdomain option is checked. This is for blogs in the format of username.yourdomain.com.
There are two steps that need to be done to your server in order for this to work.
In Apache, there needs to be a line in the domain’s virtual hosts section as follows:
ServerName yourdomain.com
ServerAlias yourdomain.com *.yourdomain.com
DocumentRoot /your/doc/root/
ServerAdmin webmaster@yourdomain.com
** If you’re running an Nginx server, you’d use:
server {
listen 80;
server_name domain.com *.yourdomain.com;
}
The Server Alias line with the *.yourdomain.com is what controls this. If you do not have access to change this, ask your webhost for support. More and more hosts are enabling this by default.
The second thing that needs to be done is adding the DNS record. Where you add it depends on your domain hosting. Basically, you need to add a line like this:
*. in A YOURIPADDRESS
These wildcards mean that any subdomain request will fall through to the WPMU install, where MU will look up the name in the database. If it finds it, it serves up the blog.
Note: if you choose the subfolder option on installation, you do not have to do either one of these steps.

Wednesday 6 July 2011

Resolving Domain Park Wrapper Errors

If you run a more populated shared hosting server, sooner or later you’ll have received complaints about the dreaded park wrapper errors in cPanel that occur when a user tries to add a parked or addon domain to their cPanel. The errors may look like this:
Error from domain wrapper: domain.com is owned by another user.
Error from domain wrapper: Domain already exists, it was not added.
I’ve never really been able to attribute that error to a specific action, but my assumption is that it occurs as a result of the end user not completely removing the domain from their cPanel (i.e. hitting esc or closing the browser during removal), therefore not allowing cPanel to remove the domain’s entries to allow that domain to be re-added when certain security settings are enabled in WHM > Tweak Settings.
The easy solution to the first error is to enable the option for users to add domains owned by other users via WHM > Tweak Settings. But this is a very bad idea as it essentially allows users to repoint domains that you’re already hosting.
If you’re attempting to re-add a domain to a cPanel account and are getting one of the above errors, first check that the error needs to be corrected. Meaning, make sure that the domain in question isn’t already set up elsewhere. If it is, you would need to remove it from that account before being able to add it to another.
If the error is actually occurring due to an improperly removed domain, follow the below steps until you are able to add the domain back to the server:
  1. run /scripts/killdns  on the server to remove the DNS records from the DNS cluster
  2. do grep -r /var/cpanel/users to see if it exists in a user file, and if so, delete the entry and run /scripts/updateuserdomains, make sure it’s remove from /etc/userdomains
  3. grep -r /var/cpanel/userdata to see if the domain appears in a user’s template. If so, remove any files based on the domain name (including .cache files), and remove any subdomain/parked/addon domain entries for that domain from the ‘main’ file located in that user’s folder (i.e. /var/cpanel/templates/username/main), then /scripts/rebuildhttpconf to remove it from httpd.conf .
This should allow you to re-add the domain name to the user’s cPanel without getting the park wrapper error.

Tuesday 5 July 2011

Updating to WP 3.2 generates a fatal error code


Fatal error: Call to undefined method Arras_Widget_Tag_Cloud::WP_Widget_Tag_Cloud() in /home/XXXXX/public_html/wp-content/themes/arras/library/widgets.php on line 404/405
To fix this, simply replace line 404 of /library/widgets.php from:
function Arras_Widget_Tag_Cloud() {
$this->WP_Widget_Tag_Cloud();
}
to:
function Arras_Widget_Tag_Cloud() {
parent::__construct();
}