Tuesday, February 24, 2009

To protect a directory with .htaccess in Fedora

A folder or directory of the public documents can be protected to prevent unauthorized visitors from seeing its contents using "HTTP authentication"

Create a file named .htaccess in the directory you want to protect and put following into file:

AuthType Basic
AuthName "Secure Area"
AuthUserFile /etc/httpd/conf/htpasswdfile
Require valid-user

Save the file and exit.
Now create the htpasswd file at given location.

cd /etc/httpd/conf

htpasswd -c htpasswdfile admin

Here one user 'admin' and password file 'htpasswdfile' is being created with the command 'htpasswd'
It will prompt for password (2 times), supply the password.

## (Some how apache, the web server user is not able to read the password file if you place the file in /root and /home/ folder so keep the file in the location where the httpd.conf file is)

## Make sure AllowOverride is set to All in the httpd.conf file

Tuesday, February 17, 2009

Amazon EC2 Server Setup

Assuming you already created account on AWS ans S3 so you will be having:
EC2 Private Key
EC2 Certificate Key
User ID
S3 access key
S3 secret key

Download Amazon EC2 API Tools from here:

The command line tools used here require Java version 5 or later to run. Either a JRE or JDK installation is acceptable.

Unzip it at some location.
Let say on /root/amazon
Also assuming you have your EC2 Private Key & EC2 Certificate Key at /root/amazon/ec2

Set these in your environment. Open .bash_profile file and add these entries as below:


export PATH

export JAVA_HOME

export EC2_HOME


export EC2_CERT

After closing the .bash_profile file run the following command:
source .bash_profile

Finding a Suitable AMI:
ec2-describe-images -o self -o amazon | grep machine
ec2-describe-images | grep public

Generating a Keypair:
ec2-add-keypair gsg-keypair
Save the output content in a file (ex: id_rsa-gsg-keypair)

chmod 600 id_rsa_gsg-keypair

ec2-run-instances ami-86e90eef -k id_rsa_gsg-keypair
Note down the instance id (i-56a32e3f). This may be different for you.

ec2-describe-instances i-56a32e3f

(Note the Public URL ec2-174-129-185-64.compute-1.amazonaws.com, this may be different for you)

Authorizing Network Access to Your Instances:
ec2-authorize default -p 22
ec2-authorize default -p 80

Connecting to your Instance:

ssh -i id_rsa_gsg-keypair root@ec2-174-129-107-244.compute-1.amazonaws.com

root@my-instance #
After login to the ec2 server start the services
Start the Apache Web Server:
[root@ip-xx-xxx-xx-xxx:~] /etc/init.d/httpd start
Start the MySQl Server
[root@ip-xx-xxx-xx-xxx:~] /etc/init.d/mysqld start
Start the Asterisk Server
[root@ip-xx-xxx-xx-xxx:~] amportal start

Point the browser at:

Congratulations !! you have running Asterisk server with FreePBX and latest sugar.
To Access sugar:
(User/Pass: admin/admin)

Whats new in Ajuby 0.5