wordpress

Google Street Map can’t work in WordPress 3.2 Solved!

25 Jul , 2011  

I tried to embed Google Map into WordPress 3.2 and see it’s works without any failure. But, not with Google Street Map. When i trying embed this javascript code, it’s only show boxes and not images.

I thought it was my NGINX configuration or w3-total cache plugin conflict with Google Street Map. So, i try installed brand new WordPress and use this code Google Street Code :

1
2
<div id="pano" style="width: 400px; height: 300px"></div>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script><script type="text/javascript">function init() {var fenway = new google.maps.LatLng(42.345573,-71.098326);var panoOptions = {position: fenway,addressControlOptions: {position: google.maps.ControlPosition.BOTTOM},linksControl: false, panControl: false,zoomControlOptions: {style: google.maps.ZoomControlStyle.SMALL},enableCloseButton: false};var panorama = new google.maps.StreetViewPanorama(    document.getElementById("pano"), panoOptions);}window.onload = init;</script>

Guess what? It’s still not works! When i use plain test.php inside wordpress, this code work succesfully. So, this is not about .htaccess, nginx configuration or something outside WordPress.

Right now i’m still searching way to make it fixed. I will updated this post soon after success embed Google Street Map into WordPress 3.2.1

Updated
I found the problem! It’s because Twenty Eleven Themes issue. Change your themes into Twenty Ten and you got Google Street View works!

Also, i posted this problem in http://wordpress.org/support/topic/google-street-view-not-work-in-twenty-eleven-themes?replies=1#post-2245186

Updated
I found solution, this Google Street View not loaded images because max-width CSS in style.css.

1
2
3
4
5
.entry-content img,
.comment-content img,
.widget img {
    max-width: 97.5%; /* Fluid images for posts, comments, and widgets */
}

You can choose 2 solution here :

1. Delete .entry-content img and you got Google Street View works. ( Not recommended )

2. Use “max-width: none” in Google maps image container.
http://wordpress.org/support/topic/twenty-eleven-12-breaks-embedded-google-maps?replies=3. Kudos to http://wordpress.org/support/profile/iorinne

,

system

Uninstall Xcache and solving error Failed loading cannot open shared object file: No such file or directory

23 Jul , 2011  

When you got this

1
"Failed loading /usr/lib/php5/20090626/xcache.so:  /usr/lib/php5/20090626/xcache.so: cannot open shared object file: No such file or directory

This because you not removing xcache configuration from php.

In this example, i using php5-fpm. If you’re using apache2 + php5, so you can find it on /etc/php5/apache2/

How to solve this problem:

1
1. Removing extension="xcache.so" from /etc/php5/fpm/php.ini
1
2. Delete file xcache.ini /etc/php5/fpm/conf.d

,

Server

Phpmyadmin blank page using Eaccelerator

23 Jul , 2011  

When you using eaccelerator, somehow it have effects with Phpmyadmin. It’s seems this happen because Eaccelerator can’t compiling Phpmyadmin in good way and should be disabled when we want to use Phpmyadmin. So, open your php.ini, there should be configuration like this :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
eaccelerator.enable = "1"
zend_extension = "/usr/lib/php5/20090626/eaccelerator.so"
eaccelerator.shm_size = "16"
eaccelerator.cache_dir = "/var/cache/eaccelerator"
eaccelerator.optimizer = "1"
eaccelerator.check_mtime = "1"
eaccelerator.debug = "0"
eaccelerator.filter = ""
eaccelerator.shm_max = "0"
eaccelerator.shm_ttl = "0"
eaccelerator.shm_prune_period = "0"
eaccelerator.shm_only = "0"
eaccelerator.compress = "1"
eaccelerator.compress_level = "9"

Change

1
eaccelerator.enable = "1"

into

1
eaccelerator.enable = "0"

and restart your php5-fpm / apache2 service to disable Eaccelerator when you using Phpmyadmin.

,

Server

How to optimize WordPress in EC2 in very overkill way!

20 Jul , 2011  

When i wrote this thing, i’m actually put my sites for testing. I’m running micro (612 MB) instance EC2 which there are Drupal, CodeIgniter and WordPress in same servers. I thought that WordPress have more resource than anothers. So i start to optimize this server and WordPress in Overkill way!

First, i assume you already have NGINX + PHP5-FPM + APC installed. If not, you can check at my Drupal 7 sites which talking about Configuring & Optimizing EC2 Instance.

Now, here the steps for optimizing wordpress.
More…

,

Server

NGINX configuration for WordPress 3.2 Single and Multiple Sites

18 Jul , 2011  

Using WordPress with NGINX will boost page load. Configuration NGINX needed for enabling permalinks / rewrite URL in WordPress. There are 2 NGINX configuration for WordPress depend on what mode will used. If you have single WordPress only, then you should use this configuration :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
server {
         server_name lanuka.com;
         rewrite ^ http://www.lanuka.com$request_uri? permanent;
}

server {
        listen   80;
        server_name www.lanuka.com;
        root    /var/yodi/wordpress/lanuka.com;

        client_max_body_size 10m;
        access_log  /var/log/nginx/access.log;
        index  index.php index.html index.htm;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }
 
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
 
        location / {
                # This is cool because no php is touched for static content
                try_files $uri $uri/ /index.php?$args;
        }


        # Add trailing slash to */wp-admin requests.
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;


        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ .php$ {
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

        location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }

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

More…

,

system

One engine for several / multiple sites in WordPress 3.2 domain using NGINX

17 Jul , 2011  

Multiple sites in WordPress 3.2, by default, it’s only supported on subdomain. But, we want create multiple sites by one wordpress engine on several domains. We want this wordpress serve independent domain. Just like what Drupal have, WordPress can do thing too (not in easy way). I will use pydemo.com as example.

What we will do?

1. Checking WordPress on Fresh or already installed.
2. Add DNS Wildcards.
3. Set NGINX configuration to works with wordpress multiple sites.
4. Enable multiple sites feature in WordPress 3.2 which it disable on default installation.
5. We need WordPress MU Domain Mapping plugin to redirect WordPress into independent sites.
More…

,

php

How to create template system layouts in CodeIgniter 2.0

17 Jul , 2011  

Templating in CodeIgniter, it’s mean we should make your own layouts system. If you have using CakePHP before, then you see there no automatic templating views in CodeIgniter. After searching and compare with anothers, i get Philsturgeon template is near with CakePHP template system ( http://getsparks.org/packages/template/show ).

So, first step, download and install it. See the installation guide to make your step easier. I assume you have installed the template into your CodeIgniter successfully. I load this template system in autoload.php $autoload['libraries'] = array('database','session','template');.
More…

,

configuration

NGINX configuration for CodeIgniter 2.0

17 Jul , 2011  

This is my NGINX configuration for running CodeIgniter 2.0.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
server {

    listen   80; ## listen for ipv4

    server_name ci;
    root        /your-public-html;
    access_log  /var/log/nginx/yourdomain.access.log;
    error_log  /var/log/nginx/yourdomain.error.log;

    # If file is an asset, set expires and break
    location ~* .(ico|xml|gz|xml.gz|css|js|gif|jpe?g|png)(?[0-9]+)?$ {
        expires max;
        break;
    }

    location / {
        index  index.php index.html index.htm;

        if (-f $request_filename) {
            expires 30d;
            break;
        }

        if (!-e $request_filename) {
            rewrite ^(.+)$ /index.php?$1 last;
            break;
        }

    }

    location ~ .php$ {
        fastcgi_send_timeout 1800;
        fastcgi_read_timeout 1800;
        fastcgi_connect_timeout 1800;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME /your-public-html/$fastcgi_script_name;
        include fastcgi_params;
    }


    location ~ /.ht {
        deny  all;
    }
}

@kudos to Buclar :
If you get some problem, then you should set uri_protocol to $config['uri_protocol'] = ‘REQUEST_URI’;

,

php

Solving RSS Feed error in Codeigniter 2.0

17 Jul , 2011  

There are several commmon error when building RSS Feed in CodeIgniter 2.0. Somehow we made mistakes and here are top list case.

When we got ErrorException [ Parse Error ]: syntax error, unexpected T_STRING, this happen because you have PHP short_tags enabled, which means <? is shorthand for <?php and opens a PHP code block.

To fix this, turn off short_tags in php.ini or code like this :

1
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>

Another problem is Line Number 1, Column 2: <?xml version="1.0" encoding="utf-8" ?>. This usually happen because we close our documents with ?> php tags. In CodeIgniter, we should leave our end of file without using ?>.

So, when you facing another RSS Feed error, try to check your php.ini and use CodeIgniter code behaviour.

,

php

How to fix Codeigniter blank / white page error

17 Jul , 2011  

Sometimes when we developing our Codeigniter application, suddenly it gave us White of Screen or blank page error. To solve this problem, we need to configure our PHP.ini to show error. So, if you using Ubuntu, go to /etc/php5/apache2/php.ini and edit :

1
2
error_reporting = E_ALL | E_STRICT
display_errors = On

More…

,

configuration

Solve blank page URL Rewrite CodeIgniter in Subfolder using .htaccess

17 Jul , 2011  

When we place CodeIgniter as subfolder in localhost environment, it will have some problem with URL rewrite. For example, i have http://localhost/codeigniter. So, if we using default tutorial on CodeIgniter without carefully then it will throw us into “blank page” and without any error.

Configuring Codeigniter for subfolder is easy. Here the steps :

1. Create .htaccess at root instalation folder
More…

,

php

How to use Zend Framework in CodeIgniter 2.0

17 Jul , 2011  

Combine Zend Framework with Codeigniter will give great result and cutting development time. Intergrating Zend Framework into CodeIgniter 2.0 is very easy. First, you download new Zend Framework here . After downloading, unpack it package and get Zend folder. Put this Zend folder into app/libraries in CodeIgniter.

Then, we create Zend libraries :
More…

,

system

How to disable Crontab in WordPress 3.2

17 Jul , 2011  

When page load, WordPress will doing cron stuff. This meaning, every page load by visitors, WordPress always checking what task in cron queque. If you curios how cron is working on WordPress, see this :

1
2
3
4
5
6
7
8
9
10
wp-settings.php:
+requires wp-includes/default-filters.php
-contains the action hook to the function wp_cron()

+requires wp-includes/cron.php
-contains functions that perform cron related tasks, including the wp_cron() function
-above functions make http request to wp-cron.php

wp-cron.php:
-actually does the schedule checking and executes anything as needed.

So, to disable cron in WordPress, you should define DISABLE_WP_CRON in wp-config.php.

1
define('DISABLE_WP_CRON', true);

Credit to : http://wordpress.org/support/topic/wp_schedule_event-events-dont-fire

system

How to disable comments in WordPress 3.2.1

17 Jul , 2011  

Disabling comments in WordPress 3.2 is not different as old wordpress version before. But for new guy at WordPress, it’s confusing. Actually, new WordPress hiding several option like revision, author and discussion which have disable comments feature.

So, before we can disable comments, we should show this menu in our editing Post or Page. Go to top right corner ( When you editing Post or Page ) and click “Screen Options”. There will be several options there. Click on “Discussion”. Then, scroll on bottom page and you will see option for enable / disable comments & trackbacks.

You can also switch on another Screen options like Author, slug, revisions , Excerpts and else.

How to disable comments in WordPress