Desktop File Example in Ubuntu 14.04

To create an icon on your desktop, you need to create a desktop file in the following format.

[Desktop Entry]
Version=1.0
Name=PhpStorm
Comment=Test the terminal running a command inside it
Exec=bash -c 'env JAVA_HOME=${HOME}/jdk /home/watcharin/phpstorm/bin/phpstorm.sh'
Icon=utilities-terminal
Terminal=false
Type=Application
Categories=Application;

Save this file in Directory Desktop as, for example, phpstorm.desktop.

If you have trouble launching the application, change the Exec line to the following to debug.

Exec=gnome-terminal -e "bash -c 'env JAVA_HOME=${HOME}/jdk /home/watcharin/phpstorm/bin/phpstorm.sh;$SHELL'"

Nginx Configuration for CodeIgniter

Suppose the CodeIgniter application is in /opes. Add the following configuration.

location /opes/index.php {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    fastcgi_pass   unix:/var/run/php5-fpm.sock;
    fastcgi_index  index.php;

    include fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  $document_root/opes/index.php;
    fastcgi_param  REQUEST_URI      $request_uri;
    fastcgi_param  QUERY_STRING     $query_string;
    fastcgi_param  REQUEST_METHOD   $request_method;
    fastcgi_param  CONTENT_TYPE     $content_type;
    fastcgi_param  CONTENT_LENGTH   $content_length;
}

* This configuration assumes we do not hide index.php in the URL.

Reference

http://www.farinspace.com/codeigniter-nginx-rewrite-rules/

SSH Login with Public/Private Key

Objective

You want to use Linux and OpenSSH to automate your tasks. Therefore you need an automatic login from host A / user a to Host B / user b. You don’t want to enter any passwords, because you want to call ssh from a within a shell script.

How to do it

  1. Log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase: 
    ssh-keygen -t rsa
  2. Use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine)
  3. Append a’s new public key to b@B:.ssh/authorized_keys

    cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
  4. In B, make sure the permission bits of .ssh and authorized_keys are 755 and 644, respectively.
  5. From now on you can log into B as b from A as a without password.

Reference

http://www.linuxproblem.org/art_9.html