Thursday, June 20, 2013

PuttyGen pem to ppk

For Amazon Web Services EC2 instances, AWS will generate a .pem file.

To use a .pem key with Putty, run PuttyGen. Select Conversions -> Import Key. Select the .pem file. Choose "Save Private Key" -- save to .ppk file.


To use with Putty, for your session, select Connection -> SSH -> Auth. Under "Private key file for authentication" browse for the .ppk file. Don't forget to save your session settings AFTER loading the key or you will have to do this every time.


Tuesday, June 18, 2013

How to change nginx root directory

Update the /etc/nginx/sites-enabled/default file -- change the document root directive in the server section

 server {  
     #listen  80; ## listen for ipv4; this line is default and implied  
     #listen  [::]:80 default ipv6only=on; ## listen for ipv6  
     root /usr/share/nginx/www;  
     index index.html index.htm;  
 ...

By default the root is installed in /usr/share/nginx/www.


How to restart nginx after updating configuration

The best way to restart nginx server after updating the configuration (/etc/nginx/sites-enabled/default or /etc/nginx/nginx.conf) is to not restart it at all. Instead, send it a kill command with the hangup (HUP) argument

# kill -HUP `cat /var/run/nginx.pid`

/HUP
...
     name. There is no default. Typing kill  does not send a sig-
     nal  to  the  current  job. If the signal being sent is TERM
     (terminate) or HUP (hangup), then the job or process is sent
     a CONT (continue) signal as well.

Code Formatter for Blogger / BlogSpot

I've been using http://codeformatter.blogspot.com/


apt-get install gives 403 Forbidden on Ubuntu 12.04 LTS EC2 Instance

I was unable to use apt-get install to install nginx on a fresh Ubuntu 12.04 LTS EC2 instance. Apt-get was returning 403 Forbidden for the ec2 ubuntu connections.

The error looked like:

 Reading package lists... Done  
 Building dependency tree  
 Reading state information... Done  
 The following extra packages will be installed:  
  libgd2-noxpm libjpeg-turbo8 libjpeg8 libxslt1.1 nginx-common nginx-full  
 Suggested packages:  
  libgd-tools  
 The following NEW packages will be installed:  
  libgd2-noxpm libjpeg-turbo8 libjpeg8 libxslt1.1 nginx nginx-common nginx-full  
 0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.  
 Need to get 403 kB/882 kB of archives.  
 After this operation, 2,691 kB of additional disk space will be used.  
 Do you want to continue [Y/n]? y  
 Err http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates/universe nginx-common all 1.1.19-1ubuntu0.1  
  403 Forbidden  
 Err http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates/universe nginx-full amd64 1.1.19-1ubuntu0.1  
  403 Forbidden  
 Err http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates/universe nginx all 1.1.19-1ubuntu0.1  
  403 Forbidden  
 Failed to fetch http://us-east-1.ec2.archive.ubuntu.com/ubuntu/pool/universe/n/nginx/nginx-common_1.1.19-1ubuntu0.1_all.deb 403 Forbidden  
 Failed to fetch http://us-east-1.ec2.archive.ubuntu.com/ubuntu/pool/universe/n/nginx/nginx-full_1.1.19-1ubuntu0.1_amd64.deb 403 Forbidden  
 Failed to fetch http://us-east-1.ec2.archive.ubuntu.com/ubuntu/pool/universe/n/nginx/nginx_1.1.19-1ubuntu0.1_all.deb 403 Forbidden  
 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?  

The solution was to run update on apt-get

 sudo apt-get update  

For more details, see: https://bugs.launchpad.net/ubuntu/+bug/987182