HTTPS on localhost

There is a quick tip !!

Sometimes we need to set up SSL on our localhost AKA development environment it can be done with self signed SSL certificate  here a quick guide to setup it on localhost

 tadaaaaa (you can google (or stackoverflow) it if you want but I make it easy)

I'm using Ubuntu Amp Stack (Apache2)

if you don't have it you can start by installing  Apache2
you need root access so I don't like to type sudo every time
so open up terminal

$ sudo -i

enter your password

# apt-get install apache2

once apache is installed you can enable the SSL module 

# a2enmod ssl

and restart the apache

# service apache2 restart

now we are halfway done Now we need a  SSL certificate   you can buy a one from a vendor or signed a one for yourself

lets go with  self signed SSL certificate  
first we need a place to store it (i'm using to store them inside apache2 config )

# mkdir /etc/apache2/ssl 

now we going to create a certificate that valid for one year (365 days)  you can change the valid period by -days argument

 # openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

it will show something like this

You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. 
----- Country Name (2 letter code) [AU]:
yeh its LK bitch
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Pawul Sansthawa 
Unit Name (eg, section) []:
ane manda
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
ok you can enter any funny thing but Common Name (e.g. server FQDN or YOUR name) []: should be

open up the SSL config file

# nano /etc/apache2/sites-available/default

(seriously  nano progamers use vim noh)

append this things to the file  look for tags and other stuff

<VirtualHost *:443>
  ServerAdmin webmaster@localhost
  DocumentRoot /var/www
  <Directory />
    Options FollowSymLinks
    AllowOverride None
  <Directory /var/www/>
    Options Indexes FollowSymLinks Multiviews
    AllowOverride None
    Order allow,deny
    allow from all
  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/apache.crt
  SSLCertificateKeyFile /etc/apache2/ssl/apache.key

 save and exit the file

reload the host file with following command (we do not care about warnings right )

# a2ensite default

now reload the apache 

# service apache2 reload

we are done done !

open your browser and go to

tadaaaaa let accept the new certificate and work with https stuff


Uploading A File on a Remote server to another FTP over SSH

If you work with remote server you may needs to upload your backup into a remote FTP server
if your remote server does not support for FTP .
the one way to do it is download your file in to local machine over SSH and upload it Over FTP
damn it may like 2x data usage (time too)

but you can use curl to do the dirty work for you
most *nix servers come with curl .. if not you can install with out any hassle

curl -v -T "<file path to zip or tar.gz>" ftp://username:password123@my.ftp.com/<path to ftp location>/

loving it right  you can remove -v part if you know what the fuck you do and want to save more kbs over SSH

and here few more curl command thats you must Know 
need to save a file 

curl -o myfile.txt http://www.abc.com/text/me/mytest.txt

download from FTP ok

curl -u ftpuser:ftppass -O ftp://ftp_server/backup/mybackup.zip

once you are in love with curl here is a bones 

curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*<name>(.*)<\/name>.*$/$2 - $1/'

replace username:password with your gamil credentials 

ok enf fun with curl --- but feel free to post your own ones


Is It Me ....

Well you have questions :D

  • Yes I'm Back 
  • NO .. but little bit butt hurt-ed
  • well see I may write in sinhala again 
  •  Cool 

let get in to point ..

I'm typing this in Sunday morning probably hating myself
what is the reason for that
next week is a holiday week for middle east , no upcoming releases

Any way I did major career switch that means I completely change my base language from JAVA to PHP
I was not a PHP guy

what I see in decision (I have done bad decisions .. even I can't remember one good decisions that I made in last 15 years )  it was not hard I thought

PHP is full of OOP features .Grate frameworks nearly kick ass much as  Hibernate and tiles .
the transition was swift

I joined as an Intern . surprisingly after 3 months the call me in as a permanent employee
lot of new things to come up I guess

working with top level archtech in SL .. and yes meeting with David Axmark ! yeh he is the founder of mysql 

but I'm still in my studies wondering witch path to select we will see it in next level I'm so Confused :D