• Shell script to get all WordPress databases and URL’s

    Below you will find a simple script that you can use to find all the databases and URL’s associated to wordpress sites in a shared database. This script requires a SQL user with the ability to ‘show databases’ and access to the DB’s you want to query.

    The script grabs a list of all the databases on the server then loops through them all retrieving the URL from the wp_options table. The script also takes into consideration the fact the the table might not actually be wp_options (could contain some random characters) so we use a wildcard there.





    Read the rest of this entry »

    Share
  • Useful commands to run in a terminal

    With the 1000’s of commands used over the years I sometimes forget what I have run. This post is a collection of commands that have been useful for me in the past and might be useful to others too. All commands are set to run from local(.).

    CREATE AN SSH TUNNEL (remember -i if using pem):

    ssh -C2qTnN -D 8080 user@location

    FIND ALL FILES/DIRECTORIES WITH XXX PERMS AND CHANGE IT TO XXX:
    Files:

    find . -type d -perm 0XXX -exec sudo chmod XXX {} \;

    Directories:

    find . -type f -perm 0XXX -exec sudo chmod XXX {} \;

    Read the rest of this entry »

    Share
  • Reverse Proxy from IIS Website to WordPress

    Our client has a corporate site at www.domain.com hosted on IIS and the blog hosted on a subdomain on a separate LAMP server at blog.domain.com. Our client feels serving their blog up under www.domain.com/blog will help their SEO and they will rank better (this is debateable but what client wants is what they will get).

    The objective of this project is to serve a wordpress site on a linux server under a subdirectory on IIS. In order to accomplish this we need to setup IIS to act as a reverse proxy, thus serving the the wordpress site under the desired blog subdirectory.

    The first step is to make sure your version of IIS is compatible (IIS 7+). Once you have determined this, you will need to install the Application Request Routing Module. The easiest way to go about installing these is using the




    Read the rest of this entry »

    Share
  • 301 redirect all subdomains to new domain on apache

    While trying to consolidate many subdomains under one new domain on apache we had to add the following into the sites configuration file to redirect the multiple subdomains to one. This could be added into the .htaccess as well.

    
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^newdomain.com$ [NC]
    RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301]
    

    Read the rest of this entry »

    Share
  • Merging 100+K Gzipped Files Together

    In order to open a large volume of cloudfront logs in a spreadsheet, we needed to merge over 100K .gz files on OS X Maverick into a single file. Trying to use the following command resulted in a /usr/bin/cat: Argument list too long error:

    cat logs/*.gz >> combined_logs.gz 

    The reason this error occurs is because bash expands the asterisk to all matching files, producing a very long command line. To circumvent this problem the xargs command needs to be used to split up the list:




    Read the rest of this entry »

    Share