Share a poem with everybody

If

(Rudyard Kipling)

If you can keep your head when all about you

Are losing theirs and blaming it on you;

If you can trust yourself when all men doubt you,

But make allowance for their doubting too;

If you can wait and not be tired by waiting,

Or, being lied about, don’t deal in lies,

Or, being hated, don’t give way to hating,

And yet don’t look too good, nor talk too wise;

If you can dream – and not make dreams your master;

If you can think – and not make thoughts your aim;

If you can meet with triumph and disaster

And treat those two imposters just the same;

If you can bear to hear the truth you’ve spoken

Twisted by knaves to make a trap for fools,

Or watch the things you gave your life to broken,

And stoop and build ‘em up with wornout tools;

If you can make one heap of all your winnings

And risk it on one turn of pitch-and-toss,

And lose, and start again at your beginnings

And never breath a word about your loss;

If you can force your heart and nerve and sinew

To serve your turn long after they are gone,

And so hold on when there is nothing in you

Except the Will which says to them: “Hold on”;

If you can talk with crowds and keep your virtue,

Or walk with kings – nor lose the common touch;

If neither foes nor loving friends can hurt you;

If all men count with you, but none too much;

If you can fill the unforgiving minute

With sixty seconds’ worth of distance run -

Yours is the Earth and everything that’s in it,

And – which is more – you’ll be a Man my son!

Django Dairy 2: It works~

The little foolish boy come back to struggle with Django.

Today, I do not have much time to work on it. I have to write a Help file for my application which is a boring issue…… but no one will help me in my company, I have to work on it myself…… using my poor poor English. Fortunately, this time nobody will spend their time on the stupid Help File…… well, in this case, my working on Help File will worth nothing… Anyway… Let’s go back to my little Django Project~~~

Today, I should work on PHP issue.

The installation works fine. But my Apache will not recognize PHP…

Well, first I found while I try to start Apache, there will be some warning like:

Warning: DocumentRoot [/opt/local/apache2/docs/dummy-host.example.com] does not exist
Warning: DocumentRoot [/opt/local/apache2/docs/dummy-host2.example.com] does not exist

I know it is the problem of

httpd-vhosts.conf

I delete the useless virtual hosts in the file, and only left one host for testing. This warning gone.

But I still got 404 error, whatever I tried http://127.0.0.1/index.html or http://127.0.0.1/index in my FireFox…

Not Found

The requested URL /index was not found on this server.

http://kanstech.blogspot.com/2010/12/apache-error-phpmotion-requested-url.html

The site listed above gave me the hint.

When you setup PHPMotion video website you will encounter the following error first,

The requested URL /upload-media was not found on this server.

It happens due to the error in Apache Config. Add the following Directory Element to the config file.

<Directory “/var/www/htdocs/htdocs”>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

If you face the problem like me, I think this time I can say some trick about it

Just go to httpd.conf of your Apache, mine is at  /opt/local/apache2/conf/

Type

sudo  vi /opt/local/apache2/conf/httpd.conf

in your shell, and search for the Directory you use for web root, see if you give the right permission, for my case,  I gave “deny from all” to my root directory, now I changed it to “Allow from all”.

Finally, my index.html in the DoucmentRoot of Apache works fine.

I saw It works~~~, really happy.

Next, what’s going on of my PHP testing file phpinfo.php?

<?phpphpinfo();?>

I found everywhere, at beginning I thought my PHP is not installed correctly.

But it should installed well. Next, I found the point, I use TextWrangler to edit phpinfo.php file at first, but now I try to use vi to open it, I found lots of unexpected characters exists at the top of the file. So I remove it, and phpinfo.php works well.

Here, I tell everybody a trick, I think maybe I am the last one know it, haha~~

Here, if you do not like vi, and you have to use root user permission to open a text file, you can use TextEdit for example:

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit phpinfo.php

Till now,  Apache works, MySql works, PHP works,

So next, I tried to install phpMyAdmin
another problem came out, Chris Gilmer said to modify config.inc.php like this:

<?php
$i = 0;

$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = ‘config’;  // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = ‘root’;         // MySQL User
$cfg['Servers'][$i]['password'] = ‘mypassword’;  // MySQL Password (only needed with ‘config’ auth_type)

/* Server parameters */
$cfg['Servers'][$i]['host'] = ’127.0.0.1′; // was ‘localhost’;
$cfg['Servers'][$i]['port'] = ’3306′;
$cfg['Servers'][$i]['connect_type'] = ‘socket’; // was ‘tcp’;
$cfg['Servers'][$i]['compress'] = false;

/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = ‘mysql’;
$cfg['Servers'][$i]['socket'] = ‘/tmp/mysql.sock’;

$cfg['UploadDir'] = ;
$cfg['SaveDir'] = ;

?>

But it does not work for me, my phpMyAdmin said 2002 error, complaining about the ‘mysql.sock’ issue.

But, I know my MySql works fine the socket is working. So that I use  nestat -ln|grep mysql   to look for the TCP status.

System told me:

8a5c5f0 stream      0      0          f745b2c                0                0                0 /opt/local/var/run/mysql5/mysqld.sock

I noticed that it is using /opt/local/var/run/mysql5/mysqld.sock

And I also check by

mysqladmin5 -u root -p variables

mysqladmin5 -p version

All of them told me the location of .sock is not $cfg['Servers'][$i]['socket'] = ‘/tmp/mysql.sock’;

So I change it to $cfg['Servers'][$i]['socket'] = ‘/opt/local/var/run/mysql5/mysqld.sock’;

And also used

sudo vi /opt/local/etc/php5/php.ini

to change the mysql.default_socket.

mysql.default_socket = ‘/opt/local/var/run/mysql5/mysqld.sock’

And still phpMyAdmin is not working correctly.

Finally, I changed config.inc.php to the content followed:

sudo vi /opt/local/www/phpmyadmin/config.inc.php

*/
$i = 0;

/*
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = ‘cookie’; //Authentication method(config, http or cookie based)?
$cfg['Servers'][$i]['user']=’root’; //mysql user
$cfg['Servers'][$i]['password'] = ”;
/* Server parameters */
$cfg['Servers'][$i]['host'] = ‘localhost’; // was ‘localhost’
$cfg['Servers'][$i]['port'] = ”;
$cfg['Servers'][$i]['connect_type'] = ”; // was ‘tcp’
$cfg['Servers'][$i]['compress'] = false;

/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = ‘mysql’;
$cfg['Servers'][$i]['socket'] = ”;

Everything is ok. phpMyAdmin works.

The next step is very easy just follow the article. And my mod_wsgi  works well.

After I installed Django, I use  django-admin.py startproject mysite

and python manage.py runserver to test django. Yes, it works fine.

Now, what I should do is to hook django with Apache to finish all my environment setup.

But it is still not a easy task for me.

I read various article talking about it

http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

http://blog.stannard.net.au/2010/12/11/installing-django-with-apache-and-mod_wsgi-on-ubuntu-10-04/

And all of them can not solve my problem, I always got     ImportError: No module named django.core.handlers.wsgi  by using

tail /opt/local/apache2/logs/error_log

to check the error log.

Finally, I found a solution. Here I list all my setting for it

/opt/local/apache2/conf/extra/apache_django_wsgi.conf    (this file is used for httpd.conf as VirtualHost referenced file)

<VirtualHost *:80>
ServerName simpleknow.djangoserver
DocumentRoot “/Users/zsspkx/workingspace/web/simpleknow”

<Directory “/Users/zsspkx/workingspace/web/simpleknow”>
Order deny,allow
Allow from all
</Directory>

Alias /media/ “/Users/zsspkx/workingspace/web/simpleknow/media/”
<Directory “/Users/zsspkx/workingspace/web/simpleknow/media”>
Order deny,allow
Allow from all
</Directory>

WSGIScriptAlias / “/Users/zsspkx/workingspace/web/simpleknow/apache/django.wsgi”

<Directory “/Users/zsspkx/workingspace/web/simpleknow/apache”>
Order deny,allow
Allow from all
</Directory>

</VirtualHost>

/workingspace/web/simpleknow/apache/django.wsgi  (this file is created by me to help apache to load WSGI handler)
import os
import sys
sys.path.append (‘/Library/Python/2.6/site-packages/’)
path = ‘/Users/zsspkx/workingspace/web’
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = ‘simpleknow.settings’
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

You can see the file above, I add sys.path.append (‘/Library/Python/2.6/site-packages/’) to this file, since for MAC, django is installed under this path.

So now my Django can run on Apache.

However, I still have one problem left, after I modify setting under my site folder

DATABASES = {
‘default’: {
‘ENGINE’: ‘mysql’, # Add ‘postgresql_psycopg2′, ‘postgresql’, ‘mysql’, ‘sqlite3′ or ‘oracle’.
‘NAME’: ‘simpleknow’,                      # Or path to database file if using sqlite3.
‘USER’: ‘root’,                      # Not used with sqlite3.
‘PASSWORD’: ‘mysql’,                  # Not used with sqlite3.
‘HOST’: ”,                      # Set to empty string for localhost. Not used with sqlite3.
‘PORT’: ”,                      # Set to empty string for default. Not used with sqlite3.
}
}
try to use mysql through Python, My site is wrong. It told me Error loading MySQLdb module: No module named MySQLdb

I download MySQLdb and follow README
$ tar xfz MySQL-python-1.2.1.tar.gz
$ cd MySQL-python-1.2.1
$ # edit site.cfg if necessary
$ python setup.py build
$ sudo python setup.py install # or su first

build will fail. And I check Google, found I should do this way:

http://cd34.com/blog/programming/python/mysql-python-and-snow-leopard/

tar xzf MySQL-python-1.2.3c1.tar.gz
cd MySQL-python-1.2.3c1
ARCHFLAGS=’-arch x86_64′ python setup.py build
ARCHFLAGS=’-arch x86_64′ python setup.py install

The build and install passed, but my problem is not solved, I still face the warning.

Maybe this have to leave tomorrow, since it is very late today.

Django Dairy 1

Here is a new story, I try to use my poor English to record the days struggling with Django and related Web Technology. A big challenge for me~~

Some days before, I meet a programmer in a start-up meet. and heard about Django. A really interesting web framework using python.

At that time, I just wished to create a new site, and I think this is the time to learn new things.

However, the story between me and Django is not so sweat at the beginning. Since I am not a web guy, I do not familiar with Python, MySql also Apache, or anything related with Web……

I am a C programmer, and after that I used C++, C# and so on, but just for embedded system or window application. I only did some Joomla issue or HTML coding before. Now I can say I am facing a totally new world. This is the most exciting news for me!

Before, my trip of Django, I have to set up the environment of it, I have one laptop, one MAC mini, one windows desktop. I am newbie for MAC, and being attracted by it. So now, I turn to MAC world. I decide to set up a MAMP environment on MAC.  I heard of that I should stop MAC default web server, and installed a new one, I do not know is it right or not, but I just followed.

My habit, go the Google type in MAMP, and I saw a very fantastic work, MAMP(http://www.mamp.info/en/index.html), and first tried to use it, but I got stuck… while I am trying add
LoadModule wsgi_module modules/mod_wsgi.so
in httpd.conf to load wsgi module for Apache which is recommended by Django.

It is not working. Either my Apache will not work, or my MySql. I can not get through it. So that I drop this way, and decided to installed it separately.

I found a article writing about Django working on MAMP by just put MAMP Django two words in Google searching box.

It is a blog written by Chris Gilmer, it is really helpful. I followed this article to setup everything up.

But it mostly depends on Mac Port, forgive my ignorant, I know nothing about it before. What can I do is just following the words it said.

But, things will not work in this way.

It will really good till I come this step:

To improve security of the mysql server configuration, please run mysql_secure_installation5 script and configure mysql password for root, network access, etc:

$cd /opt/local/bin

$mysql_secure_installation5

System asked me to input password……,  I do not remember I have set up any password before, I tried everything I can come through, and system still do not let me go…

Finally I found a way to resetting the root password of MySql at

http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

I used the Generic Instructions to pass my problem.

At the step of Starting/Stopping Apache and MySQL, I got to know what a fool I am……

first, I followed the way article told me, nothing happened……

After that my teacher Google told me that I should modify the file named ~/.tcshrc  not ~/.cshrc so I did it. And it will not work, and bring me more error, at last I got to know, the syntax of alias is not right.

The article write like this

#
# Apache Aliases
#
alias apache2ctl ‘sudo /opt/local/apache2/bin/apachectl’

#
# MySQL Aliases
#
#alias mysqlstart ‘sudo /opt/local/bin/mysqld_safe5 &’
alias mysqlstart ‘sudo /opt/local/share/mysql5/mysql5/mysql/mysql.server start’
alias mysqlstop ‘/opt/local/bin/mysqladmin5 -u root -p shutdown’

#
# PHP Aliases
#
alias php ”/opt/local/bin/php”

But what works for me is following this format:

#
# Apache Aliases
#
alias apache2ctl=”sudo /opt/local/apache2/bin/apachectl”

#
# MySQL Aliases
#
#alias mysqlstart ‘sudo /opt/local/bin/mysqld_safe5 &’
alias mysqlstart=”sudo /opt/local/share/mysql5/mysql5/mysql/mysql.server start”
alias mysqlstop=”/opt/local/bin/mysqladmin5 -u root -p shutdown”

#
# PHP Aliases
#
alias php=”/opt/local/bin/php”

I know I am not familiar with all the things I faced, maybe I made a stupid mistake, but anyway I got this point, And I will continue try it tomorrow.

归位

十年磨一剑, 霜刃未曾试. 
今日把示君, 谁有不平事? 

哈哈,我赵烁回来了!2年,毕业了。曾经在国内也算是一番风顺,曾见也算是小有作为,曾经也算是得到很多认可。
出来了,什么都不是。学习,生活,各方面压力一度压得我透不过气。锐气,信心,一切都被打磨得越来越少。
毕业了,找工作,本以为凭着身上的本事,还会没有施展的场所?
感情,本以为一味的喜欢,还会有不是?
没吃过太多的苦,和以前相比,身份,生活,情感,所有的所有,全都压在了身上。
失落,痛苦,挫折,一切与谁说?本来就是一个不喜欢吐露心事的人,一切都憋在了肚子里。
不过,想想,所有的一切,自己扛着,也都一步步走过来,一个个目标一个个的达到。
也不悔这样的拼搏。我就是这种不服输的人,不服气,我就不信了,所有的努力没有回报。
我就不信了,一身的本事,无法施展。
抬抬头,看看,天空不是一样的那么蓝吗!
想想,我不是一样这样生存吗!
没什么大不了,我赵烁回来了!不服输的我!一样的坚持,永远不回头!哈哈哈

相信

无法让自己忘掉你的笑容,
无法让自己忘掉你的气息,
无数的黑夜里出现了幻觉,
仿佛你还在我的身边,
我们依旧欢笑着,
可白天,将美梦哄走的时刻,
只剩我一个人在原地,
只好不断的欺骗自己,
其实你还在等我,
等我回到你那里去,
一切都可以变得像原来一样美秒。
现在我多想大声向你喊,
我爱你,我也多么想听见那句很久没有听见的我也爱你
可一切只能在我的美梦里经历了。

别傻了

当说尽所有情话,面对只是冰冷的面孔,
你还能坚持多久。
当话已经说到绝对的地步,
你还会傻傻的等待期盼吗。
当微笑已经不属于你,
再多的泪水能挽回什么。
别傻了,孩子,
不是没有路,只是你不愿前行。

不要去期待什么

每天白天,每天晚上,总是期待那个图标为我而亮。
而多少个日子,无论说什么样的话,
这个图标已经不会为我再闪动,
哪怕是对我咒骂,
我也想它能再次活跃的跳动,
没有,没有一次主动的跳跃,
冷,冰冷的气息,让我感觉透骨的冷,
我已经不知道如何面对,
因为我知道,我已经失去了。
失去了之后,无论再如何挽回,
依然于事无补,可我真的不想放弃,
内心的争执,真的如此痛苦。
哪怕你给我回复一下,说让我放弃吧,
我不会再为你闪亮,
连最后这样的话都没有。
真的对我这么无情,这样的话都吝惜吗。
我不要去再期待什么了,
既然如此,我也只好把希望都抛掉,
轻装,再一次,独自走在自己的路上。
失去原有的温暖。
虽然冷,但我还能坚强的走下去。
我不会让任何人看我笑话,
我只会越活越好,越活越精彩。
为了我说过了,你放弃了我,但我没有放弃过我的誓言。

日子一天天过

呵呵,看看自己前一篇日记。期盼一些事情开花结果。确实开花了,结果倒是不知道。
很可惜,自己真的有些方面无能为力,一味强求,只知道傻傻的给,
而不懂得真正的经营,真的好想哄得你每天都开开心心的。
可是,我无法做到,当你不高兴的时候,只知道为你担心,为你着急,为你想办法,却忽略了还要把你逗开心。
当我们之间碰到问题的时候,我被问题迷惑了。却忘记了你是那么的脆弱,容易受到伤害。
现在,说什么都有点晚,你将心再次对我关闭,无奈我如何敲门,都没有回答,
其实是我的问题,我无法,也没能力真正进入到你心灵深入,
天真的我,还是一些简单的想法。
其实,爱才是最需要学习的东西。
爱你,却不懂你,伤害了你,我不知道该怎么对你说对不起。

偶然

人总是想自己计划自己一切,将所有的命运掌握在手中。可是又有几个能够做到完全遵循自己的路线行走呢。
我们总是被四周的环境,外界的因素所压破扭曲着。所划出的人生轨迹很多时候总是由很多偶然所构成。
当你所期待的不来得时候,我们沮丧,我们懊悔,当事实与你说想的不尽相同的时候,我们郁闷,我们抱怨。
但是我们无法真切的说出,事情的改变到底对自己是什么样的影响。好和坏都无从分辨。
很多事情发生于意想不到的时候,当你想要得到什么的时候,上天给你些迹象,给你先甜头,好像唾手可得的时候,
它又无情的将这些收回,将你的期盼打入囚牢。而当你苦闷之时,它又善良的撒给你了希望的种子,只要你可以好好
播种,也许将来就是一片良田。
我们无法预测将来会怎样,但是我们不能因为现在的困难,而不敢接受上天再次的恩惠,也许上天只是在恰当的时候,
来告诉你什么才是你的,什么才是你应得的。我期盼着这些种子,开花,结果。

病有很多种,外在的身体的病,心理变态的病,内里神经系统的病,很多很多。
造成病的原因也有多样,物理损伤,心理创伤,老弱衰竭,但有一种病是很特殊的,心灵的疾病。
有首歌说,思念是一种病,确实,思念的痛苦有时候是隐隐作痛,有时候确实撕心裂肺。很难描述。
当你心灵受了伤,是否有也有药可以医治,还是只能等待时间来慢慢地让伤口结上疤,之后的日子也许还会撕裂一些,还会反复作痛。
其实我相信心灵的病也是有药可医的,但是也要对症下药。得了什么心病,就要下什么药。
所以,很多时候,有些人责备某人说在找什么替代品,安慰剂,不是的,是因为他的心受伤了,他需要药的医治。
以前,我很不理解,一个人心灵伤了,怎么会好得这么的迅速,现在我明白了,因为他找到了正确的药,值得他付出的药。
我的心若是伤了,我希望也能找到一副对症的药,也许我已经找到了,不是什么烈性的药,只是静静地可以医治创伤就好。