Archive for » September, 2009 «

Sunday, September 27th, 2009 | Author: darvil

Why Chinese? Most of my friends do not know how much Chinese culture has influenced me. It is a similar story to how Japanese culture has shaped me. Although for the past few years Chinese influence on my life has waned somewhat as I focus a lot of my time on computers and networking. But lets roll back down on memory lane.

I grew up in Thailand and when I was a kid, Chinese wuxia series were hugely popular. I use to run home all the time from school to watch the series. Yet I watched them dubbed in Thai so I never even knew their real names. Even now in my head I can remember some story lines and cool stuff that I wish I can find to watch it again. At the same time of my fascination with the series, Chinese movies also entered my imagination. This of course is mainly movies from Hong Kong. Actors such as Jackie Chan and Jet Li really kicked ass and who doesn’t like any of their movies. The more darker and fantasyish movies like the bride with white hair, fallen angels, and the blade captured the essence of what I considered cool and gritty back in the days. Of course, I still recall when stormriders came out and blew my mind and most of my friends who are into Chinese movies. One of my newer goal in life is to play the newer updated game in Chinese and actually be able to play it.

Chinese culture also made an entry into my gaming habits. There were of course the mindless hack and slash like Dynasty Warriors series but those I never really played much. The one series of games that captured my imagination was a similar game to civilization (which sucked me up). It was called Romance of the three kingdom which was based off the novel. Since I couldn’t read Chinese I played the translated version which was old but was incredibly addictive. From this game I learned of that period of Chinese and became familiar with many of the great characters such as Lui Bei, Cao Cao, Zhuge Liang, etc. I used to create characters in game based on my friends and then of course try to take over China with them. Looks like there’s a new ROTK11 is translated into english. I gotta make some time for that.

When I got to the US, and during my period of isolation, I went deep into Chinese entertainment. This was mainly in the form of HK movies. I bought many dvds (ordered 30 at a time from HK) and watch many of the classics and became familiar with many famed Chinese directors such as John Woo, Wong Kar-wai, Tsui Hark, Ronny Yu and Zhang Yimou. I became huge fans of actors/actresses such as Brigitte Lin, Leslie Cheung, Tony Leung, Maggie Cheung, Gong Li, Chow Yun Fat, etc.. I wasn’t just into action and fantasy now. I started delving more and more into artsy and dramatic movies and started to appreciate the more intricate stories woven into these masterpieces.

After this eventually I got to the point where I bought and read the translated novel of Romance of the Three Kingdom which was comprised of 4 books. Since I have always been interested in ancient history (At one point I wanted to be a history major), I started reading Chinese history and listened to recorded college lecture such as The teaching company’s lecture on Chinese history. Of course I also became interested in politics and social issues during this period so I read the more recent history on China. I read biography by Jan Wong on China and read up on Mao and try to understand modern China. One day I saw Nicholas D. Kristof and Sheryl WuDunn being interviewed on cspan about their upcoming book. I snatch up the book which was called China Wakes: The Struggle for the Soul of a Rising Power. Of course the situation in China is moving so fast that half of these books are probably outdated. In any case, I am fully aware of China and especially its rising economic might.

I don’t know what are the reasons for many of the people who learn Chinese in my class. Most probably are learning it because its a smart thing to do with the growth of Chinese power. For me though its both a practical and genuine interest in Chinese culture. I also consider Mandarin a beautiful language (although Thai got it beat for now) and it is a challenge for me. Its actually the first language I will study to learn because the 3 I speak right now I obtain just by growing up around them. Hopefully I can learn well and use the resources I have to improve my Chinese. It definitely is a long commitment.

Sunday, September 27th, 2009 | Author: darvil

I have wanting to install nginx to run sarnworld forum for a very long time now. Previously, there were other sites that were on the same machine so finally the past summer I moved sarnworld to its own machine. Now I finally have done it although with a few bumps along the way which I know alot of members probably were irritated by ;) . I say that because really I don’t need to install anything. The default setting is fine (with apache) because I have alot of resources to throw at the site but as a geek you want to just try to milk more out of your system so I went ahead and did this. Some of the roadblocks that I ran into were because SW was now running on invision forum version 3 which was a bit more picky and had some things which took some work to get it to work on nginx.

These are the road blocks I ran into in order

1.) forum wouldn’t work due to me not including the reflection option in the php compile
2.) nginx had permission problem with the graphics on the forum and the base domain couldn’t load up.
3.) nginx had an issue with the new FURL which uses htaccess so nginx config had to be modified
4.) The wiki also needed a bit of modification on nginx config to work
5.) Ran into a problem in compiling the modules
6.) nginx had 502 errors after loading up the caching modules

First I referenced an old post I made before (SW video site link)

I did the php-fpm install. Edit the php-fpm.conf file and make sure to change the user and group.

Of course on the php compile you should do it your way just make sure you include –enable-fpm and –enable-reflection

./configure --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --disable-pdo --disable-debug --enable-pic --enable-inline-optimization --with-xml --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-xslt --enable-memcache --enable-zip --with-pcre-regex --with-mysql --with-mysql-sock --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --without-sqlite --enable-reflection

I then compile nginx in the default folder and modules

Along the way I referenced This Site

But when I ran the pecl command I got this error

ran into the "pecl.php.net is using a unsupported protocal - This should never happen." error

To fix this error I found this link

Found the 2 channels and deleted them

/usr/local/lib/php/.channels/
/usr/share/pear/.channels/

Then I ran

pear update-channels

Now I go onto to install the 3 modules on the other link.

/usr/local/bin/pecl install memcache
 
Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so'
install ok: channel://pecl.php.net/memcache-2.2.5
configuration option "php_ini" is not set to php.ini location
You should add "extension=memcache.so" to php.ini
/usr/local/bin/pecl install apc
 
Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/apc.so'
install ok: channel://pecl.php.net/APC-3.0.19
configuration option "php_ini" is not set to php.ini location
You should add "extension=apc.so" to php.ini

I ran into an error on the 3rd module.

/usr/local/bin/pecl install syck-beta
 
checking for syck files in default path... not found
configure: error: Please reinstall the syck distribution
ERROR: `/tmp/pear/temp/syck/configure' failed

Found the solution on this link.

I followed the instructions.

http://rubyforge.org/frs/?group_id=224&release_id=2202

wget http://rubyforge.org/frs/download.php/4492/syck-0.55.tar.gz

untar, ./configure, make, make install.

ran the command again

/usr/local/bin/pecl install syck-beta 
 
configuration option "php_ini" is not set to php.ini location
You should add "extension=syck.so" to php.ini

I then edited php.ini and added all the modules

Now I discovered Nginx had permission issue (403 error) with loading up the graphics on the forum. I posted here and here.

I wished I saw the latter post which gave me the correct because it took me a bit of time to figure it out. It was basically a counter intutitive solution. Initially I thought it was php-fpm which was the issue but it was actually nginx. Basically it was the user line that I had to add.

I also had to add extra stuff to get mediawiki to work with nginx. I used this link as a reference.

Here is my nginx config

Make sure you include

user usertim usergroup;

if the files in the domains are owned by the user and group.

On the top of the nginx.conf file

domains part of the config. Note that I had to include both /discuzz and discuzz/ just in case some people include a / at the end. This setting is with FURL enabled with .htaccess in IPB3.

$INFO['use_friendly_urls'] = '1';
 
server {
  listen 80;
  server_name  www.sarnworld.com;
  root /blah/blah;
  location / {
    index index.php index.html index.htm;
    }
 
# This is your php-fpm section.  Replace it accordingly (For example if you decide to run it on a different port).
  location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
 
 }
 
  location /discuzz/ {
    index index.php index.htm index.html;
    try_files $uri $uri/ /discuzz/index.php?q=$uri;
   }
 
location /discuzz {
    index index.php index.htm index.html;
    try_files $uri $uri/ /discuzz/index.php?q=$uri;
   }
 
# This is for nginx to deny access to .htaccess file.
  location ~ /\.ht {
            deny  all;
          }
     }
 
server {
  listen 80;
  server_name wiki.sarnworld.com;
  root /blah/blah/blah;
  location / {
    index index.php index.html index.htm;
  }
 
# This is your php-fpm section.  Replace it accordingly (For example if you decide to run it on a different port).
  location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
   include        fastcgi_params;
  }
 
#without this mediawiki wouldn't work
 location ~  ^/index.php/(.+) {
           rewrite ^/index.php/(.+) /index.php?title=$1 last;
       }
 
# This is for nginx to deny access to .htaccess file.
  location ~ /\.ht {
            deny  all;
          }
 
     }

I ran into another issue where if i load the APC extension in php.ini, nginx gives a 502 error and everything dies.

I found this thread but it didn’t give me any clues.

Finally I found this thread which let me know that Zend optimizer was conflicting with APC.  Great clue.  I needed ioncube loaded for some encrypted mod I was using on the forum but I didn’t need zend optimizer so I edited php.ini and commented all lines with zend_extension_ except for the one that loads ioncube.  Restarted php-fpm with apc extension loaded and the site wasn’t throwing the 502 errors anymore.

WOOHOO

Now to install memcache and get it to work you need a dependency (libevent). Found link for a reference.

installed memcache according to that and ran using this command. 

/usr/local/bin/memcached -u root -d -l 127.0.0.1 -p 11000 -m 128

It runs on port 11000 and uses up to 128 megs of ram and localhost

Now I activate APC and Memcache on sarnworld

edited conf_global.php file in IPB to enable the 2 caching softwares. I had to send a ticket in IPB customer service to ask how to do it. It turned out to be pretty simple as the support is built in.

For APC add in.

$INFO['use_apc'] = '1';

for Memcache

$INFO['use_memcache'] = '1';
$INFO['memcache_server_1'] = 'localhost';
$INFO['memcache_port_1'] = '11000';

According to the IPB tech if you have more the 1 memcache server, just duplicate the last 2 lines, increasing the server and port numbers.. server_2, server_3, etc…

Now to get into APC settings in detail I found this link for a reference.

edit php.ini and I added these entries.

[apc]
 
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 30
apc.optimization = 0
apc.ttl = 7200
apc.user_ttl = 7200
apc.num_files_hint = 2000
apc.mmap_file_mask = /tmp/apc.XXXXXX

Then make a symlink to the apc.php to a web accessible location to see the statistics.

ln -s /usr/local/lib/php/apc.php /blahblah/apc.php

It seems that I don’t really need memcache so I may just close it off in the future. Most recommendations seem to be just to enable APC and it would be good enough but for now why the heck not. Just run it all since I have all the resources. I want to improve the speed of the forum ;)

On a side note I found this memcache link for mediawiki but I will work on that later ;)

Tuesday, September 08th, 2009 | Author: darvil

So I’ve been attempting to upgrade the forum (currently 2.3.5) to 3.0.2 but I keep running into problems.

It all started off when I see this error “ALTER TABLE ibf_members CHANGE id member_id MEDIUMINT(8) NOT NULL auto_increment;
Duplicate entry ‘1′ for key 1″

After this my member_id table get deleted and it causes a chain reaction of errors that made it impossible for me to upgrade the forum.

After spending a few hours, I finally found the solution.  First I found an IPB thread that talked about something “funky” on the members table.

Well my brain finally noticed something strange on the members table.  Basically THE FIRST RECORD I had was a 0 with no username (just a blank), this was what was the problem.  I deleted that first record and everything started working.  Incredible that I didn’t see this from the beginning.

DOH!