Archive

Posts Tagged ‘web’

Upgrading to Nginx and getting WordPress to work

June 24th, 2009 Jacken 2 comments

So, after doing an upgrade of my Apache installation all my web content stopped working. It continued to give 403 errors. After spending hours changing permissions and checking every little detail I gave up. So I installed Nginx instead. It’s a bit scary to start using a totally new web server software, but why not live dangerously? Anyway, it’s fast! Really fast. The only problem I had was to get all the redirects to work. And I also removed my gallery2 installation and moved the blog to /

Problems

It took longer than I had anticipated, mainly because I had to learn how to set up Nginx, but also because of the trouble of getting answers when searching the net. But here’s my working config (mostly saved for me if I forget :)

server {
    listen   80;
    server_name  www.jackenhack.com
            jackenhack.com;
    keepalive_timeout  5;
    tcp_nodelay        on

    access_log  /var/log/nginx/access.log;
location ~* ^.+\.(xml|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
root /var/www/nginx-default;

}

    location / {
        root   /var/www/nginx-default;
        index  index.php index.html index.htm;
gzip            on;
  gzip_http_version 1.0;
  gzip_comp_level 2;
  gzip_proxied any;
  gzip_types      text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    #include /etc/nginx/wordpress_params.super_cache
    #include /etc/nginx/enable_wordpress;

    # rewrite old blog url
    rewrite ^/blog/(.+)$ /$1 permanent;

# 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 /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 . /index.php last;
}

}
# setup for jackeniax
        location /jackeniax {
            root   /var/www/nginx-default/jackeniax;
            index  index.php index.html;

            if (!-f $request_filename) {
                rewrite  ^(.*)$  /jackeniax/index.php?q=$1  last;
                break;
            }

            if (!-d $request_filename) {
                rewrite  ^(.*)$  /jackeniax/index.php?q=$1  last;
                break;
            }

        }

        location ~ \.php$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  /var/www/nginx-default$fastcgi_script_name;
                include        /etc/nginx/fastcgi_params;
        }

    # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
                deny  all;
        }

}

Categories: web Tags: , , ,

MAMP WordPress and Error establishing a database connection

March 20th, 2009 Jacken 4 comments

I’ve installed MAMP on my Mac to do some changes to my blog. I tried to set the WordPress wp-config.php file to connect to localhost:8889, but got an error that It could not connect to the database. After replacing localhost:8889 to 127.0.0.1:8889 it works. My quick guess is that permissions for the root user is set to allow connections 127.0.0.1, but not localhost. Anyway, it works now.

My wp-config.php file looks like this:

define('DB_NAME', 'wordpress');
/** MySQL database username */

define('DB_USER', 'root');

/** MySQL database password */

define('DB_PASSWORD', 'root');

/** MySQL hostname */

define('DB_HOST', '127.0.0.1:8889');