502 Bad Gateway

Suddenly, i would get a 502 Bad Gateway page while trying to access my localhost nginx web server.

Looking at nginx log, found these

$ cat /var/log/nginx/error.log
---
2014/06/26 00:26:10 [crit] 1260#0: *2 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "localhost"

I remembered having firing the system updater few hours ago. Looking at the logs

cat /var/log/apt/history.log

I see php5-fpm, php5-mysql, php5-common, php5-readline, php5-cli have been updated. I guess this is what caused the breakup.

I tried re-installing them
$ sudo apt-get install --reinstall php5-fpm
---
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
libwebkitgtk-3.0-0 : Depends: libjavascriptcoregtk-3.0-0 (= 2.4.2-1ubuntu0.1) but 2.4.3-1ubuntu2 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

I ran
$ apt-get -f install

Apparently the last update didn’t complete. But i’m still getting the 502 error :-/

But then googling more about the nginx log, someone posted a magical solution here


$ chmod 666 /var/run/php5-fpm.sock

Problem Solved 😀

mcrypt on Ubuntu Server

I tried installing Prestahop and Laravel on an Ubuntu Server and it was telling me mcrypt function cannot be called.

Tried doing this but it said it was already installed
sudo apt-get install php5-mcrypt

I finally edited php.ini adding
extension=mcrypt.so

It could have been done using this too i guess
sudo php5enmod mcrypt

It’s kinda weird why this wasn’t enabled by default.

Pundit Sungkur et al. refuse to return our stolen beach.

Last time, they said they’ll do everything to abide by the law [ ref ] despite having violated it at first. But now they are waiting for the law to abide to their plan [ ref ]. They are waiting.

This government is a joke. “Petit copains” can piss on the laws and regulations. Government don’t care. But what they do, install speed cameras that fine the general population Rs 2000 if they go at 80.1 km/h. This is them saying they’re just doing their duty by applying “The Law”!

Power of Scroll Wheel

If the scroll wheel of the mouse was to be connected to a dynamo, i guess the we would have enough electricity to power space exploration for at least a decade 😛

On a more serious note, what if the scroll wheel could really recharge wireless mice (plural of mouse)? Wouldn’t that be awesome?

Getting nginx with PHP and MySQL

I managed to install nginx on my laptop. Apache used to eat a lots of my precious RAM previously. My laptop got a mere 3GB of it :-/. I hope nginx would make Web Development much more pleasing as well as allowing my laptop to do other stuffs as well.

Installing nginx is not as straight forward as installing the famous LAMP (Linux, Apache, MySQL and PHP). It requires quite some file configuration ninja skills. Following the tutorial found here.

It was kinda tricky to config the config file ‘/etc/nginx/sites-available/default’.

I was un-commenting everything in the curly braces after ‘location ~ \.php$’ like a dummy. nginx would fail to start. After doing

$ nginx -t

It told me:-
nginx: [emerg] “fastcgi_pass” directive is duplicate in /etc/nginx/sites-enabled/default:61
nginx: configuration file /etc/nginx/nginx.conf test failed

After scanning the file and showing some attention to what was going on, i noticed that i was supposed to un-comment only part for ‘With php5-fpm’ so as it appears like this


location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

I was feeling too lazy to install phpMyAdmin for database administration. Thought of why not using the command line.

$ mysql -p

The mysql terminal opened.

CREATE DATABASE mybb;

And it worked. I could install the beta version of MyBB Forum software 1.8 😉