Archive for Linux

WordPress post update services and Nginx upstream time out

Starting around last Friday, I think, this site became irresponsive. Checking Tengine/Nginx error logs, here is a sample of what I saw:

2014/03/xx 08:43:40 [error] 3837#0: *6149 connect() to unix:/var/run/php-fastcgi/php-fastcgi.socket failed (11: Resource temporarily unavailable) while connecting to upstream, client:, server:, request: "POST /xmlrpc.php HTTP/1.0", upstream: "fastcgi://unix:/var/run/php-fastcgi/php-fastcgi.socket:", host: ""
2014/03/xx 08:45:13 [error] 3837#0: *6151 upstream timed out (110: Connection timed out) while reading response header from upstream, client:, server:, request: "GET /wiki/doku.php?id=wiki:dokuwiki HTTP/1.0", upstream: "fastcgi://unix:/var/run/php-fastcgi/php-fastcgi.socket", host: "", referrer: ""
2014/03/xx 08:46:00 [error] 3837#0: *6159 upstream timed out (110: Connection timed out) while reading response header from upstream, client:, server:, request: "GET /category/technology/mysql/feed/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fastcgi/php-fastcgi.socket", host: ""

So I started researching. A number of web pages, including StackOverflow, recommended increasing values for some or all of the following Tengine/Nginx parameters, so time out wouldn’t occur:

  • fastcgi_read_timeout
  • proxy_connect_timeout
  • proxy_read_timeout
  • proxy_send_timeout

Those suggestion appeared to be reasonable. So I tried raising those parameter values one at a time. Their default value is 60 seconds. I raised them to 600 just to test.

In my case, the problem persisted. The only difference was that the site suffered a slower death and the few minutes it was able to stay alive, the site was terribly slow and unacceptable.

At this point I’d spent hours debugging this. I decided to give myself a break and come back to it the next day. Before falling asleep, I wrote down a note of checking some reputable forums the search engines may not necessarily able to get, such as Linode’s forums. Failing that, I am determined to read up on more documentation and code to get to the bottom of this.

It turned out that Linode’s forum provided the necessary clue to finally resolve this. The problem lies in the WordPress blog publishing update service. The idea behind it was to notify blog aggregators like Technorati/Feedburner (remember them?) as soon as you publish a blog. One of the aggregator sites listed in my WordPress setting decided to not accepting those notifications anymore. Not knowing this, WordPress still tries to send notification out in vain, which caused the whole mess. After removing that URL, everything went back to normal.

On your WordPress admin page, you can find which URL your blog pings to by going to: Settings -> Writing -> Update Services. Update: The same problem happened again. So I removed also. Now my WordPress does not ping or update anybody. So far the site has been stable.

Hope this helps!

Lesson learned/reinforced:
After working on a problem for a long time and you are stuck, take a break, go for a walk, find a friend to talk to and describe the issue and what you’ve done thus far. You’d be surprised at how effective this can be.

Comments (2)

Setting up ownCloud

I’ve spent some of my spare time lately researching on ways to have better control of my calendar, contacts, important files that I sync to different places, and such. My objective is to move those things away from big cloud providers like Google, Microsoft, Dropbox, Skype, and so on. I am happy to report that the open source solution ownCloud provides just what I needed. I was able to set it up today and the tests were successful. Here are some noteworthy points.

  • ownCloud provides clients for Windows, Mac, Linux, iPhone, and Android devices, which is really nice;
  • In my case, the only php component missing was the php GD module. After installation, I restarted my VM and then it worked fine. For database, I used MySQL;
  • Setup was easy. I did the manual install by following instructions here. My web server was Tengine, a fork of Nginx. I used the sample Nginx configuration in the instruction page as the starting point, and it worked just fine;
  • ownCloud recommends using SSL, which I concur. I spent some time researching on certificate options, and decided to use self-signed certificate. The reason is simple: the intended customer is me and my family, therefore I don’t need a Certificate Authority (CA) to tell me that I am using a site that I own :) Not forking out the cash is added bonus. Note, though, that if you are running a commercial site that conducts transactions online, it is necessary to purchase certificates and enable SSL. That’s not the right time to be penny-pinching (or a 铁公鸡);
  • To generate my own self-signed certificate, I followed instructions here. I used the 2048 bit key. I followed the optional step 5 so that I can start Tengine without providing a password;
  • I think ownCloud will be great for companies and teams. If you have control to a web server, which most companies and teams do, then more than likely you’ve got the infrastructure to have your own cloud. For a company/team, I do recommend purchasing SSL certificates, unless your company/team is pretty small;
  • Don’t forget to renew your self-signed certificate as time moves closer to its expiration date. In my case, the validation period is one year. I’ve already set a reminder for me.
  • I’ve really enjoyed using dnsimple. Separating DNS and hosting service really gives me great flexibility in learning and testing out different web technology.

Hope this helps. Let me know if you have comments/suggestions.

Comments (2)

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
*** 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. 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, That site currently hosts a wiki I setup years ago, just for testing. And I have plans to host open source projects 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.

Comments (1)

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
tar xzf tengine-1.5.1.tar.gz 
cd tengine-1.5.1/
./configure --user=www-data --group=www-data --with-http_ssl_module
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.


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

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.


« Previous entries