Author: troy

htaccess force SSL for WordPress

This works for me on Apache 2.2 with VirturalHosts. Plus other useful stuff here. <IfModule mod_rewrite.c> RewriteEngine On Options -Indexes Options +FollowSymLinks RewriteBase / # Force HTTPS RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}/$1 [L] # Deny access by your most hated visitors and bad bots RewriteCond %{HTTP_USER_AGENT} mechanize [NC,OR] # Protect against SQL INJECTION RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [OR] RewriteCond %{QUERY_STRING}...

Format USB and Unzip img to memory stick

Insert the USB stick Type [sudo fdisk -l] [enter] (-l is lower case L) You should see a line: Disk /dev/sdb: xxxxMB, xxxxxxxxxxxxxxbytes LOOK FOR > sdb < NOT sda the xxx should roughly match the size of the USB memory stick >> This confirms the device we want is sdb there should be NO * under Boot [a] –...

Virus and Trojan Advice

Install more than 1 browser on your computer. 3 is ideal. Only read email with one (Iceweasel is my preferred) and only THAT ONE. On THAT ONE install the plugins: HTTPS Everywhere No Script (don’t enable any suspect websites to run scripts) Click&Clean (use it) Dont open email that you are not certain it is safe. If it comes from...

Mark Bad Blocks Check Hard Drive Linux

Which disk? sudo fdisk -l Non-destructive read-write test If you want to preserve your data try this first sudo badblocks -svn /dev/sdb smartmon Check to see if your fix worked sudo apt-get install smartmontools sudo smartctl –all /dev/sdb sudo smartctl -A /dev/sdb sudo smartctl -a /dev/sdb | grep -i reallocated Use DD to automatically mark bad blocks – destructive if...

[Webmaster Tools] http://www.example.com/: Googlebot can’t access your site

I am posting this unsolved mystery – as an ongoing problem – instead of posting to a forum. Comment if you like. I’l update when I find the solution. I get the typical message from Google [Webmaster Tools] http://www.example.com/: Googlebot can’t access your site. I run LAMP servers with Netfilter (iptables) with PSAD and Fail2ban. I check iptables for any...

How To Use DD to Wipe Hard Drive

Helpful to know which device is which fdisk -l Will write zeros to sda dd if=/dev/zero of=/dev/sda bs=1M Write random numbers to sda dd if=/dev/urandom of=/dev/sda bs=1M Wipe the MBR dd if=/dev/zero of=/dev/sda bs=446 count=1 or just add the partition number to sda to wipe certain partitions Creates an ISO disk image from a CD-ROM; in some cases the created...

fail2ban.actions.action: ERROR iptables -D

fail2ban.actions.action: ERROR iptables -D INPUT -p tcp -m multiport –dports http,https -j fail2ban-apache-xxxxxxxxxxxxxxxxxxx iptables -F fail2ban-apache-xxxxxxxxxxxxxxxxxxx iptables -X fail2ban-apache-xxxxxxxxxxxxxxxxxxx returned 200 iptables only allows rules of up to 30 characters Shorten the name of the conf file solves the error

How To Solve Swappiness (Apache) Problem

Swappiness is a Linux kernel parameter that controls the relative weight given to swapping out runtime memory, as opposed to dropping pages from the system page cache. Swappiness can be set to values between 0 and 100 inclusive. A low value causes the kernel to avoid swapping, a higher value causes the kernel to try to use swap space. The...

Install PHP for WordPress

There is not much to installing PHP except when you need more power. Sometimes WordPress needs more. sudo apt-get install php5 php-pear php5-mysql php5-cli php5-gd php5-curl curl sudo vi /etc/php5/apache2/php.ini max_execution_time = 300 max_input_time = 60 memory_limit = 256M post_max_size = 64M upload_max_filesize = 64M

Setup a LAMP Server on Debian or Ubuntu

This setup is for Virtual Host server – not a dedicated server with a single domain SSH to your server ssh root@IP Update Debian/Ubuntu apt-get update && apt-get upgrade –show-upgraded -y Create User How To Create a User in Linux Setup SSH for Remote Access With GPG Keys – No Password How To Setup SSH for Remote Access IMPORANT –...

Install Apache on Debian and Ubuntu

Install Apache sudo apt-get install apache2 sudo vi /etc/apache2/sites-available/default change AllowOverride None > AllowOverride All in line 11 Enable Apache rewrite and restart Achtung! Don’t forget or things will not work and you’ll waste hours trying to find out why sudo a2enmod rewrite Restart Apache sudo service apache2 restart If no error, its working Optional: The following “example” is used...

Solve Sourcelist Problems with Resolv.conf OpenDNS

Add OpenDNS Nameservers to resolv.conf This has solved problems seemingly unique to some service provides sudo vi /etc/resolv.conf Replace existing IPv4 addresses with openDNS nameservers or just add them above the existing IPs in your resolv.conf 208.67.222.220 208.67.220.222 Same for IPv6 addresses 2620:0:ccc::2 2620:0:ccd::2 also add to end – as last line options rotate Restart Networking sudo service networking restart...

Block All Traffic to Your New Remote Server

I block all traffic to a new server while I setup users and environment using Netfilter AKA iptables. Nothing else gets in or out of the box but me. This requires 2 scripts actually. One to close the machine to all other IPs but mine, and one to “unblock”. You need to unblock while installing other software, re. LAMP, when...