PHP Script To Change WordPress Hostname (URL)

Tech Supporton July 10th, 2013No Comments

Very often we move WordPress websites around. Whether it’s from staging to production or to a new hostname completely, you’ll need to make changes to the database in order to reflect this new URL properly. After getting frustrated of doing this manually, we looked for a better way.

Luckily, the WordPress Search and Replace Tool was exactly what we needed. Just download this file into your WordPress directory, load it in your web browser and wham! All your URLs are instantly updated.

Check it out. It’s one of our essential tools for WordPress.

Symfony, WordPress and nginx – configuration details and setup

nginxon April 8th, 2010No Comments

After several hours of trial and error, we finally figured out a configuration that works for running Symfony and WordPress together on the same web site using the nginx web server.  This post had a lot of useful information, but none of it worked perfectly for us, so this is what we came up with:

##
## domain.com
##
server {
    listen   80;
    server_name domain.com;

    access_log /home/logs/domain/access.log;
    error_log /home/logs/domain/error.log notice;

    root   /home/www/sfprojects/domain/web;
    index  index.php;
    charset utf-8;

    ## configuration for the WordPress blog with the WP-SuperCache plugin
    ## (remove if not using WordPress)
    location /blog {

        # if the requested file exists, return it immediately
        if (-f $request_filename) {
                break;
        }

        set $supercache_file '';
        set $supercache_uri $request_uri;

        if ($request_method = POST) {
                set $supercache_uri '';
        }

        # Using pretty permalinks, so bypass the cache for any query string
        if ($query_string) {
                set $supercache_uri '';
        }

        if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
                set $supercache_uri '';
        }

        # if we haven't bypassed the cache, specify our supercache file
        if ($supercache_uri ~ ^(.+)$) {
                set $supercache_file /blog/wp-content/cache/supercache/$http_host/$1index.html;
        }

        # only rewrite to the supercache file if it actually exists
        if (-f $document_root$supercache_file) {
                rewrite ^(.*)$ $supercache_file break;
        }

        # all other requests go to WordPress
        if (!-e $request_filename) {
            rewrite  ^(.*)$  /blog/index.php?q=$1  last;
            break;
        }

    }

    location / {

        # If the file exists as a static file serve it directly without
        # running all the other rewite tests on it
        if (-f $request_filename) {
            expires max;
            break;
        }

        if ($request_filename !~ "\.(js|htc|ico|gif|jpg|png|css)$") {
            rewrite ^(.*) /index.php last;
        }
    }

    location ~ "^(.+\.php)($|/)" {
        set $script $uri;
        set $path_info "";

        if ($uri ~ "^(.+\.php)($|/)") {
            set $script $1;
        }

        if ($uri ~ "^(.+\.php)(/.+)") {
            set $script $1;
            set $path_info $2;
        }

        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        include        fastcgi_params;

        fastcgi_param  SCRIPT_FILENAME  /home/www/sfprojects/domain/web$script;
        fastcgi_param  SCRIPT_NAME      $script;
        fastcgi_param  PATH_INFO        $path_info;
    }

   location /sf/ {
        root /home/www/sfprojects/domain/lib/vendor/symfony/data/web/;
   }

   error_page   404  /404.html;
   location = /404.html {
        root   /usr/local/nginx/html;
        internal;
   }

}

And this is the content of our fastcgi_params file which we include above:

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

Hope this proves helpful to someone going through the same problems!

Welcome to our blog!

Generalon October 5th, 2009No Comments

We wanted to welcome you to the blog for McComb, Inc.  We plan to use this blog to share some of the best and latest technology news that can help you as a small business. We’re constantly on the lookout for new products, ideas and technologies and we want to share the best of those with our customers and readers.

In addition to providing some useful information, a blog is a great marketing tool for any web site.  We often work with our clients to install blogs on their own sites to help with marketing, customer interaction and, of course, search engine optimization and placement.

We primarily use WordPress to power all of our blog and CMS projects. It is an incredible piece of software and completely free to use.  There is a huge installed base, and that also means that there are a ton of plugins available.  We’ll be posting in the near future about our favorite WordPress plugins, but feel free to ask us any questions that you may have in the meantime.

Thanks for stopping by!