Fixing WordPress comment email notification problem by installing sendmail on Debian

In the past, whenever a reader commented on a blog entry, I would receive an email notification. Ever since I moved this site to a Linode VM, I noticed the comment email notification stopped working. Alas, blogs are not like what they used to be back in the day, now that so many people have mobile devices and there are so many ways to waste our time. As a result, not too many people bother to comment on blogs these days. So I postponed fixing this until today.

It turns out that WordPress uses PHPMailer for email notification. Skimming through the source code of wp-includes/class-phpmailer.php, I determined that installing sendmail on my Debian VM would fix the problem.

But sudo apt-get install sendmail gave me this first:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 sendmail : Depends: sendmail-bin but it is not going to be installed
            Depends: sensible-mda but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Ok, let’s fix the broken packages then:

sudo apt-get -f install

That didn’t find any broken package to fix.

So I decided to install the dependencies separately. First:

sudo apt-get install sendmail-bin

That command generated some error output but the last message was ok:

Errors in generating sendmail.cf
*** ERROR: FEATURE() should be before MAILER()
*** MAILER(`local') must appear after FEATURE(`always_add_domain')*** ERROR: FEATURE() should be before MAILER()
*** MAILER(`local') must appear after FEATURE(`allmasquerade')*** ERROR: FEATURE() should be before MAILER()

[ ok ] Starting Mail Transport Agent (MTA): sendmail.

So I proceeded with:

sudo apt-get install sensible-mda
sudo apt-get install sendmail

Both commands were successful. I then tested sending email to myself on the command with mail, which worked fine. A test comment on my blog also resulted an email notification. So all is well.

Hope this helps you also!

Web hosting with DNSimple and Linode

After about 8 years of hosting this site with Midphase, I’ve migrated my hosting service to Linode. I am using Debian 7 as my operating system. The web server is Tengine, a fork of Nginx. (Update: I am currently using Apache.) I have root access, therefore total control of this Linode VM. And I am using DNSimple to manage my domain, which is also very nice.

Apart from having total control of the server, I found Linode’s documentation to be pretty clear and easy to follow. I am currently on the Linode 1GB plan, which works very well so far for this WordPress site. It also hosts another site, JiMetrics.com. JiMetrics hosts an open source project to gather and analyze system metrics data, initially focusing on Windows server and SQL Server administration. I recommend Linode highly. If you do want to use Linode service, I’d appreciate it if you could use my referral code so I could get some credit, 26cf3677a198d39b0728077d04c74651b0ee93c6

Most of web hosting companies bundle domain name service along with hosting service. Depending on your situation and technical knowledge, this may or may not be a good thing. I prefer separating those two nowadays, which gives me more flexibility and better control, especially when it comes down to moving hosting service somewhere else, due to lack of support and/or deteriorating performance. So for DNS, I’ve decided to use DNSimple. It has a pretty good interface and documentation. With the fixed IP address I get from Linode, I just filled out the appropriate information in my DNSimple accout for domain name resolution. I am pretty happy with it so far. Once again, if you do decide to use DNSimple, I’d appreciate it if you use my referral link so I can get some credit.

Keep up the good work, Linode and DNSimple. Don’t disappoint me and the good folks I send your way.

Setting up WordPress on Debian/Ubuntu running Tengine web server

I will change my host provider within a month. I’ve been using Midphase for several years and have decided to use Linode as my next virtual private service provider. I will move this site there in the next few weeks. This will be my first time moving a domain and I hope the transfer will be smooth without too much down time. After all, I know my readers worldwide are hanging on to every word I type and deserve a site that runs 24 by 7 🙂

Since I will have total control of this host, I decided to use Tengine, a great fork of the Nginx web/proxy server. Here is my note on how to compile and config Tengine on Debian/Ubuntu, and then setup WordPress. During my study and testing, the following sites are pretty helpful.

I followed and modified processes from all 3 sites above and made my own. It works for me so far. It is documented here and I will modify it as necessary. Right now the Tengine server only hosts one domain. I will very likely add more domains down the road. I’d love to hear your comments and recommendations. One thing that is not documented here is the installation of WordPress SuperCache plugin. I plan to use that after the site is moved.

sudo apt-get update
sudo apt-get upgrade --show-upgraded
sudo apt-get install libpcre3-dev build-essential libssl-dev
wget http://tengine.taobao.org/download/tengine-1.5.1.tar.gz
tar xzf tengine-1.5.1.tar.gz 
cd tengine-1.5.1/
./configure --user=www-data --group=www-data --with-http_ssl_module
make
sudo make install

sudo vim /etc/init.d/nginx
Please copy and paste code from here for /etc/init.d/nginx

sudo chmod +x /etc/init.d/nginx 
sudo update-rc.d nginx defaults
sudo /etc/init.d/nginx start
sudo apt-get install php5-cli php5-cgi spawn-fcgi psmisc
sudo apt-get install mysql-server php5-mysql

sudo vim /etc/php5/cli/php.ini
Please uncomment this line in /etc/php5/cli/php.ini. It should be around line 944.

; extension=msql.so

sudo vim /usr/bin/php-fastcgi
Please copy and paste code from here for /usr/bin/php-fastcgi

sudo vim /etc/init.d/php-fastcgi
Please copy and paste code from here for /etc/init.d/php-fastcgi

sudo chmod +x /usr/bin/php-fastcgi 
sudo chmod +x /etc/init.d/php-fastcgi 

Create an empty MySQL database

wget http://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz 
sudo mkdir -p /var/www
sudo cp -r wordpress/* /var/www
sudo chown -R www-data:www-data /var/www/
sudo update-rc.d php-fastcgi defaults

sudo vim /usr/local/nginx/conf/nginx.conf
Please copy and paste code from here for /usr/local/nginx/conf/nginx.conf

sudo /etc/init.d/php-fastcgi start
sudo /etc/init.d/nginx reload

Now go to http://localhost and your test WordPress site should be ready to go.

Thinking of changing hosting company

I purchased shared hosting service from Midphase years ago and that is where this site is hosted. It is up for renewal before 10/11.

Every year during this time, for the last 2 or 3 years, I toyed with the idea of switching to a different hosting company, because the inflexibility of not having root access. The current annual price from Midphase is around $136 with this breakdown: haidongji.com (MPan) $96 and DevPack – Unlimited MySQL & Subdomains $40. Here is some server specs:

# Percona Toolkit System Summary Report ######################
        Date | 2012-09-27 21:13:49 UTC (local TZ: MDT -0600)
    Hostname | some server name
      Uptime | 197 days, 12:31,  1 user,  load average: 5.87, 4.95, 4.89
    Platform | Linux
     Release | CloudLinux Server release 5.8
      Kernel | 2.6.18-374.18.1.el5.lve0.8.57
Architecture | CPU = 64-bit, OS = 64-bit
   Threading | NPTL 2.5
    Compiler | GNU CC version 4.1.2 20080704 (Red Hat 4.1.2-52).
     SELinux | Disabled
 Virtualized | No virtualization detected
# Processor ##################################################
  Processors | physical = 1, cores = 8, virtual = 1, hyperthreading = no
      Speeds | 1x2400.000
      Models | 1xAMD Opteron(tm) Processor 6136
      Caches | 1x512 KB
# Memory #####################################################
       Total | 15.5G
        Free | 500.9M
        Used | physical = 15.0G, swap allocated = 4.0G, swap used = 397.2M, virtual = 15.4G
     Buffers | 835.2M
      Caches | 5.3G
       Dirty | 254020 kB
     UsedRSS | 18.6G
  Swappiness | 0
 DirtyPolicy | 10, 80
 DirtyStatus | 0, 0

I looked at some Virtual Private System (VPS) providers. Linode’s smallest offering, Linode 512, provides 512MB of RAM and 20 gig of storage at a cost of $20 per month. NTC Hosting’s VPS Hosting vBox 1 provides 1 gig of RAM and 10 gig of storage at a cost of $20 per month. I’ve also browsed Rackspace, InMotion, and others. I don’t know, if I do decide to go with VPS, I will probably pick between Linode and NTC Hosting. Either way, it looks I need to pay $100 extra per year if I go that route. And I need to transfer domain name, which I’ve never done before. There is also the factor if my site is still accessible in China if I change hosting companies…

Anyway, if you have any recommendations on hosting service providers and comments, I am all ears.

开源软件的参与及社区互动的一些体会和建议:沟通和交流

开源上的项目有时需要和国外的人员沟通。怎样沟通,怎样建立互信,这是个非常大的题目。我把观察到的和蹦到脑子里的想法写出来。如果读者有问题,可以提出来。

我在美国待了很久了,也到过一些其他国家和地区。依我看,不管白红黄黑棕哪个国家哪个种族的人,不管你是女皇还是屌丝,本质上讲大家都是人,没大差别。大家都有七情六欲,都有那么点小可爱和小肮脏,都要屙屎放屁。和你我一样,女皇伊丽莎白的屁和屎照样臭,当然还不能排除更臭的可能。大家脱了衣服后都是那几样东西,毛或多或少,高矮大小尺寸有点不同,连披金戴银穿着红皮鞋的德裔种族主义者现任教皇也不例外,不管你外表如何的冠冕堂皇。有的还可能像奥巴马总统一样有点口臭,特别是清晨刚睡醒后那段时间(这是根据第一夫人未当选前的表述,后来她不说这个了。期待方舟子科普口臭的原因和防治)。当然这不是教你去不修边幅,形象还是很重要的,因为形象在一定程度上反映一个人有无自尊。每个国家每个地区每个宗教和无宗教的人都有人的闪光和可憎之处,部分因为经济、习惯和教育的原因,大家的表现(不少人喜欢称之为“素质”的那个东西)会有不同,这都没啥。

乱七八糟地说这些,意思就是说国外的人和你我一样,都是人。抱着以人为本的信念来互相尊重和学习,体谅和理解,知道自己的尊严、自信和底线来结交朋友。有了这个出发点和任何人沟通和交流,给你打包票,错不了。

下面来谈谈一些小建议。我以为这些建议,相关部分在本国同事之间的交流上同样管用。当提到国际友人时,我指的是所有国际友人,不管国籍、肤色、宗教信仰、性取向等。不管你是美国白人、黑人、外籍华裔,不管你来自非洲、中东、日韩、南美,一视同仁地以尊重、友好的方式来维护双方的利益。如果你不希望别人以刻板的方式来对待你,那你就不要以刻板的方式来对待别人。己所不欲,勿施于人,你要有这个风范!

1. 目前国际上交流的载体大部分是英文,所以不少人在这方面会有障碍。但不要因为有了这个障碍就不敢交流,不要因为害怕病句、拼写的错误而放弃交流。你当然要努力尽量用正确的词和句法,但如果词和语法不完美和正确但意思到了,那么这个交流就很有意义。这样一来二去,你的外语水平会提高。在本文的最后我有提高英语的小建议。另外,其他参与到开源软件的人可能来自非英语国家,他们的英语不见得比你强到哪里去;

2. 要注意名字的拼写。一般来讲,别人怎样自称,你就要用那种拼写方式,包括字母的大小写。我看到一些从国内来的电邮,其中有的不知何故的改变别人名字的大小写,请不要这样做;

3. 无论是书面还是口头交流,千万不要不懂装懂!如果你没搞明白,如果这个事情不是鸡毛蒜皮之类的小事,特别是牵扯到计划、行动、和时间安排等对他人有直接和间接影响的信息,不要敷衍了事!你没搞明白,你可以说,对不起,你可以换一种方式来解释吗?或者你可以以你的理解方式复述重要的交流信息,以此来确认和验证彼此观点和计划的一致性。千万不要在双方还没真正达成一致的情况下拍胸脯、打包票,结果损人损己;

4. 口语交流上,不要太在乎口音。能表述清楚是第一要务,所以说的时候不要着急。一般来讲说慢些会有利于理解;

5. 哈哈一笑是比较常见的沟通方式,也是化解矛盾、将就着过去的方法。另外,我们中的不少人和国际友人交流的机会不多,有好奇心甚至觉得国际友人的举止比较可爱的情况很正常。再加上语言的不便,这种有点紧张的笑声就更容易听到。但我感觉在大多数情况下,国际友人,特别是不太了解东方文化的,可能会以为这种笑对他们来讲有点奇怪甚至难以理解。这不是说面对面沟通或打电话交流时不能笑,大家都板着脸。重要的是能察言观色,观看肢体语言和表情,这方面我感觉东西方的差别不大,并根据这些观察来调整和理清模糊的观点。有些东西,一次解释不清不要紧,以后时机成熟时再提也不迟;

6. 对外交流增多,有很多人来中国,我们要逐渐适应、学习、尊重、和欣赏他们所带来的多样性和多元化。举个小例子,面对面交流时,我们尊重别人的饮食习惯,有人吃素,有人不习惯吃整的带刺儿的鱼等等。尊重别人的时间和空间,有计划并及时沟通;

7. 既然我们都是人,那么国际人士和国内同胞一样,也不乏混蛋、瘪三、种族主义者、圣人蛋、猥琐的小人混蛋之流。再加上事情的偶然性、沟通障碍、不合宜的时机等,有的项目即使我们做得很好,也可能因为各种各样的因素,我们的patch,feature set等不被接纳。在这种情况下,在合作的努力没有结果后,我们可以发布自己的分支和大家共享和进步。

拉拉杂杂,就先写这儿吧。另外,最近在微博上总结了些学英语的小建议,也在这儿先放着吧,如下。

不论哪个语言,想把东西表达清楚和准确,都要认真努力花时间下功夫,母语也是如此,何况外文。多读多写,慢慢积累。读的话,读好的原版的关于自己本身就感兴趣的主题的作品,这样读时就不会觉得枯燥,读得下去的同时可以提高词汇量,学到好的句法和表达方式。举个例子,如你喜欢伍迪艾伦的电影或乔治卡林的单口相声,就可以先在亚马逊上找关于他们的书,要读者评论口碑高的那些,然后弄来读。注意到的新词和好的表达方式,要试着用。个人体会,一些新的词和句法,如果能在合适的场合自己用过一次,就算掌握了大半。多用几次,就是自己的啦。

一开始读外文书时可以囫囵吞枣,但有的词老出现老不懂就要用字典啦。要有好的英汉字典。个人以为如果到了可以用纯英文字典来学新词并且到完全可以理解的地步,那英文水平就很不错啦。

我认为过了六级英语的同学没必要通过读报纸和杂志英语新闻来提高,因那都是肤浅空泛的八股句式,搞得人很浮躁和浮漂,蜻蜓点水一样,内功提不上去,个别的长的深度报导除外。我不是开玩笑,我觉得读《洋葱》(The Onion)学英语要比读NYT,The Wall Street Journal,Time Magazine,Newsweek等更有效和有趣。National Geographic还行,但质量也在下滑。最好是读书,安静一下,每周找个时间,沉下心来,给自己放个假,读本好书,陶冶性情,平稳而满足。在《洋葱》那里你可以逐渐理解部分美式的幽默和讽刺!祝学得愉快!