Truth

Truth. For each truth, there is an equal and opposite lie.

Some believe the truth. Some deny the truth.

Some believe the lie. Some deny the lie.

Download Youtube Videos/Audios from CLI

Everyone downloads videos and audio from YouTube. There are countless plugins for it. Some work. Some don’t. Some just redirect you to their website. Some just stalk your browsing history.

youtube-dl is the solution [1]

$ sudo apt-get install youtube-dl

Downloading Video
$ youtube-dl {videourl}

Downloading only the MP3, [2]
$ youtube-dl --extract-audio --audio-format mp3 {videourl}

Isn’t it awesome?

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.