How to Set Up Virtual Host with MAMP on a Mac OSX

Standard

1. Update the hosts file:
We are going to add an example domain named “thisdayinbangladesh.dev” as a virtual host through this tutorial. Lets first add this in the “hosts” file by typing the following command on the Terminal,

sudo nano /etc/hosts

Then find the following line,

127.0.0.1 localhost

update this to following,

127.0.0.1 localhost thisdayinbangladesh.dev

Also to add our domain to the IPv6 version find the following line somewhere bottom of the file,

fe80::1%lo0 localhost

update this line to the following one,

fe80::1%lo0 localhost thisdayinbangladesh.dev

Finally press “ctrl+x” and then “y” to save and exit this file.

2. Update httpd.conf file
Open up this file by typing the following command,

sudo nano /Applications/MAMP/conf/apache/httpd.conf

find out the following line,

#Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

It might have a “#” symbol at the very beginning of the line. Delete the symbol to activate this statement. If the line is not anywhere of the “httpd.conf” file then add the above line anywhere of this file. Now, save and exit this file.

3. Update httpd-vhosts.conf file
Now go into the “/Applications/MAMP/conf/apache/” folder by executing,

cd /Applications/MAMP/conf/apache/

If you can see a folder named “extra” then enter inside it otherwise create this “extra” folder and then enter inside it.
Now update (If there was already a “extra” folder then there should be a “httpd-vhosts.conf” file other wise just create the “httpd-vhosts.conf” file inside “extra” folder) the “httpd-vhosts.conf” file by typing the following,

sudo nano httpd-vhosts.conf

Then the final “httpd-vhosts.conf” file should have the following code block. Whether you add these lines or updated the existing file.

NameVirtualHost *:80

<VirtualHost 0.0.0.0:80>
DocumentRoot "/Applications/MAMP/htdocs"
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/Applications/MAMP/htdocs/thisdayinbangladesh/public"
    ServerName thisdayinbangladesh.dev
    <Directory "/Applications/MAMP/htdocs/thisdayinbangladesh/public">
        Options All
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Here “thisdayinbangladesh” is a project directory; actually a laravel4 project directory inside my “htdocs” folder and we added the “public” folder thats resides in “thisdayinbangladesh” folder as the document root cause laravel4 needs to point to the “public” folder as the application root URL.
In this stage of this example. You can forget about laravel4 and simply create the directory “/thisdayinbangladesh/public” inside your “htdocs” folder and place a simple “index.html” file there inside the “public” folder.

4. Restart:
Simply stop and re-start the Apache service from your MAMP control panel. Then try out the URL on your browser. http://thisdayinbangladesh.dev You should see your “index.html” file!

Important:
This tutorial will take you through out a nice series of posts on which a full laravel4 web application has been developed. That service is already LIVE HERE. So, stay tuned!

Update:
The next tutorial is ready Installing Laravel4 in Mac OSX with MAMP. So, you are another step close toward the full laravel4 application development series.

To Do List After Launching a New Linux/Unix Like Server for Development

Standard

Commands, tricks & cautions that will be used here have been tested only on a Ubuntu 12.04 VPS. Though, most of the commands should work in other Unix like system without any change.
In this lesson we will see how should a newly launched/opened server be configured for basic security & proper accessibility. Usually you get an IP address & a root password for logging in as root, as soon as you open a new cloud/vps server from rackspace/digitalocean or some others like these.

1. Connecting to the remote system through/using SSH:
SSH(Secure Shell) is a protocol used to securely loggin in to a remote system & also ssh is the tool used in Linux that connect to the remote server over the SSH protocol.

ssh root@123.45.67.890

The terminal will show a message and will prompt

....
Are you sure you want to continue connecting (yes/no)?

Type yes & press enter & then in next prompt enter your root password that was provided by that server provider while opening a VPS. So, now we are logged in to the remote system as root user.

2. Change your root user’s password:
You used the root password that was generated & provided by the server provider & the first thing is to change this password. Enter the following command on the terminal.

passwd

It will first ask the current root password & after entering the current password it will ask your desired new password twice for confirmation. Continue reading

Kohana with Twitter bootstrap: Auto Generator Shell Script

Standard

Kohana HMVC with Twitter Bootstrap Auto Generator

What it does?

  • It makes a ready to develop web app on Kohana MVC along with Twitter Bootstrap UI framework.
  • First it downloads kohana, twitter bootstrap, jquery etc.
  • Secondly it makes necessary changes on the kohana boostrap and allocates UI assets.
  • Then it creates two types of routes for accessing front end and backend of the developing app.
  • It also makes changes on the default controller class and creates a view for it.
  • Also you can create a set of MVC (model, view, controller) classes/files by using create command.
  • Finally you can open the app in browser using open command.

Installation

  1. I assuem you have downloaded the kohanastrap.sh file on your home.
  2. Open up the terminal. Change its permission by chmod +x ~/kohanastrap.sh
  3. Make a symlink of it by sudo ln -s ~/kohanastrap.sh /usr/bin/kohanastrap
  4. Type kohanastrap from inside any directory and talk with it.
  5. I assume, you will enter into yout htdocs OR www directory and type kohanastrap init and then it will build up a ready to develop web app using twitter bootstrap as template.
  6. If you want to create a set of MVC files/classes such as a Controller, a Model and a View for managing users of your app, then type kohanastrap User and Done! Check inside your classes, views directory.
  7. Finally run your web app using the command kohanastrap open and it will open your browser with two additional tabs containing the URLs of front end and backend of your newly created app (If you are in Mac). Otherwise, Open the browser and go to http://localhost/kohana/ OR http://127.0.0.1/kohana/ if you are in other than Mac.

Demo

Download

You can fork/download it from github

Precautions

Make sure wget works in your system. Also make sure your php has cURL, mcrypt, GD enabled and Apache has mod_rewrite enabled. Those are needed to kohana.

Setup a custom domain for your appfog application

Standard

www
On a previous post we saw how to deploy a PHP application in appfog using appfog CLI. appfog gives you a domain for your newly created aaplication which is not so beautiful at all. Such as (http://YOUR-APP-NAME.aws.af.cm/) or something like that according to your choosen region/infrastructure while creating the app.

Today we will point a godaddy domain to a appfog application. For this you will have to first go to your app under your appfog account. Then select the Domain Names from left navigation. Here you can see the domain name already assigned to your application and few more blank fields for domain names to be added.

Also you can see the DNS instructions for custom domains” below that form. Here it will show what “A” record and CNAME record you should add on your own domain control panel.

Screen Shot 2013-02-14 at 7.24.46 PM

I have added http://www.nuhil.net as the second domain name. Then I added a “A” record and a “CNAME” record under my godaddy domain management panel using the DNS manager.

godaddyIf you wait few hours after changing the records in your domain end, then this will point the full domain for example http://www.nuhil.net to the appfog application but if you type the naked one like, http://nuhil.net then it will show a 404 not found appfog message. For the solution I did a forwarding under my godaddy account using the “forwarding domain tool” to forward the naked domain to full domain.

Screen Shot 2013-02-14 at 7.39.38 PM

This forwarding may cause a change on your “A” record you just created manually according to appfog’s suggestion. But no need to worry. The “CNAME” can take care of all the rest.

Deploy Application in Amazon Beanstalk inside free EC2 Instance with RDS

Standard

aws-beanstalk
Amazon has virtual cloud server (instance) and many other web services. They offers a 1 year free micro tier to be used by anyone who own an international currency Debit/Credit card like Payoneer debit master card. There are several services included with the free tier that can be used along with the EC2 instance without any extra charge. Beanstalk deployment framework is one of the free services you are eligible for.

For no additional charge, AWS Elastic Beanstalk allows you quickly and easily deploy your Java, PHP, Python, Ruby, and .NET applications using many of the services offered in the free usage tier.” -Amazon. Beanstalk is similar to other deployment frameworks like appfog, pagodabox etc. Moreover if you use Beanstalk then you will still have access to your virtual cloud server in which the deployment will be running. “Behind the scenes, Elastic Beanstalk handles the provisioning of a load balancer and Amazon EC2 resources.” -Amazon. Thats why I prefere Beanstalk than others who are in my knowledge.

In this post we will cover the steps of creating an account for Amazon EC2 free tier, configuring local machine for Amazon CLI tools, creating a sample app locally, creating an elastic beanstalk php environment, deploying a sample php app, creating an Amazon RDS and connecting to it via PHP and mySQL workbench, git version controlling of the deployed app, setting up a custom classified domain to our newly deployed app environment. Tired to read these ? I am sure you will feel best after having this journey 🙂

1. Create an account for Amazon web service from here . You can see the service list that will be included with your free tier for your further using. Note that, the sign up process is simple and you will be asked to provide your card detail on the second step and finally you will have to verify your phone number. You will have to put your phone number then to click “call now” button then a 4 digit pin number will be appeared on your browser. After that an automated call will reach your phone. You should either speak the pin number slowly or input the pin number in your mobile keypad if it supports touchtone functionality. I always spoke the pin after listening the bot girl’s voice 🙂 Continue reading