Nginx 502 Bad Gateway error

October 30, 2011    |   Posted by admin   |    Category: Linux Administration

My server went down today and after restarting, it came up with a “Nginx 502 Bad Gateway” message. At first I thought its something related to the Nginx service, so restarted the nginx service but immediately realized it wasn’t the case.

Nginx receives a request on port 80 and it then proxies the request to ‘localhost’ on port 8080 (in my case) where another service is configured on it. If no service is listening on port 8080, it results in a ‘Nginx 502 Bad gateway’ message. I immediately realized it was the Java service binded on port 8080 of my server and started it.

# java -jar /home/user/test.jar

The website was online immediately.

The Nginx proxy port is defined in the Nginx configuration file and different services could be binded to the proxy port depending on your setup. It could be

1) PHP-fpm
2) php_cgi
3) FastCGI

OR could be something else. You have to start the service listening on the proxy port to get your website/application online.

Comments Off on Nginx 502 Bad Gateway error

Howto: find the Linux kernel version?

September 2, 2011    |   Posted by admin   |    Category: Linux Administration

The ‘uname‘ command is use to determine certain system information in all the Linux/Unix flavours like CentOS, Ubuntu, Debian, Fedora, FreeBSD etc. With specific ‘uname’ options, you can display all the details of the current working kernel on the server.

To display the working kernel name, version, date and time, system architecture type etc, use:

# uname -a
Linux server.domain.tld 2.6.18-164.11.1.el5 #1
SMP Wed Jan 20 07:39:04 EST 2010 i686 i686 i386 GNU/Linux

To print only the kernel version along with it’s major and minor versions:

# uname -r
2.6.18-164.11.1.el5

To print the system architecture type i.e. whether the machine is 32 or 64 bit, use:

# uname -p
i686

The /proc/version file also contains the kernel information:

# cat /proc/version
Linux version 2.6.18-164.11.1.el5 (gcc version 4.1.2 20080704 
(Red Hat 4.1.2-46)) #1 SMP Wed Jan 20 07:39:04 EST 2010
Comments Off on Howto: find the Linux kernel version?

[Ubuntu] apt-get: Package has no installation candidate

August 16, 2011    |   Posted by admin   |    Category: Linux Administration

When you try to install a package using apt-get, APT searches it’s own database for the package name, if the package is available in the database, then it looks for the repository from where to download the package. It then download the package from that repository and installs it.

If the package name does not exist in APT’s database, it does not have any idea what you are trying to install and you see the following error message:

#  apt-get install <packagename>
Reading package lists... Done
Building dependency tree... Done
Package aptitude is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package <packagename> has no installation candidate

 

So, the above error occurs for 2 reasons:

1) The APT’s database is not updated.

A quick fix is to update the APT’s database as per the defined sources list.

# apt-get update
# apt-get upgrade
# apt-get install <packagename>

This is it. If isn’t fixed, check point #2 below.

2) The package itself isn’t available on the official Ubuntu repository.

In such a situation, you have to add a 3rd party repository to your /etc/apt/sources.list file and install the package, however, try such repositories at your own risk.

Postfix postdrop: unable to look up public/pickup: No such file or directory

July 31, 2011    |   Posted by admin   |    Category: Linux Administration

The Postfix mail logs may indicate the following error when emails are not working:

postdrop: warning: unable to look up public/pickup: 
No such file or directory

It turns out to be sendmail running along with Postfix and creating issues. The fix is to stop/remove sendmail and create the necessary postfix directory and restart the postfix service.

# /etc/init.d/sendmail stop 
#  mkfifo /var/spool/postfix/public/pickup
# /etc/init.d/postfix restart
Comments Off on Postfix postdrop: unable to look up public/pickup: No such file or directory

What is equivalent/alternative of chkconfig in Ubuntu or Debian?

July 16, 2011    |   Posted by admin   |    Category: Linux Administration

The alternative / equivalent of chkconfig in Ubuntu is “sysv-rc-conf”. To install sysv-rc-conf, ssh to the server and execute:

# apt-get install sysv-rc-conf

to start managing the services, execute

# sysv-rc-conf

It’s an easy to use interface for managing /etc/rc{runlevel}.d/ symlinks.
sysv-rc-conf provides a graphical view for turning services on and off at startup.

Comments Off on What is equivalent/alternative of chkconfig in Ubuntu or Debian?