Saturday, September 28, 2013

Setting Virtual Host (VHost) on Mac OS X

1. Preparation

In this section i'm used local.mysite.dev for sample
Start Apache
1. Go to System Preferences
2. Select "sharing"
3. Check the box "Web Sharing" -- for starting the apache

2. Edit the Host file

For editing you can use nano or mate text editor for command line
sudo nano /etc/hosts
or
sudo nano /private/etc/hosts
You can see the following codes:
#
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
add new host local.mysite.dev at end of line
#
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
127.0.0.1       local.mysite.dev


3. Switch in the httpd.conf file

sudo nano /etc/apache2/httpd.conf
find the "# Virtual hosts" string using ctl + w and type "# Virtual hosts" without (")
# Virtual hosts 
#Include /private/etc/apache2/extra/httpd-vhosts.conf
un comment the code to enable the VHost
# Virtual hosts 
Include /private/etc/apache2/extra/httpd-vhosts.conf


4. Add virtual host in apache

sudo nano /private/etc/apache2/extra/httpd-vhosts.conf
add these codes:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any  block.
#
                                                                                                   
< VirtualHost *:80>
  ServerName localhost
  DocumentRoot "/Library/WebServer/Documents"
< /VirtualHost>

< VirtualHost *:80>
  ServerAdmin local@mysite.dev
  DocumentRoot "/Library/WebServer/Documents/mysite/webroot/"
  ServerName local.mysite.dev
    < directory "/Library/WebServer/Documents/mysite/webroot/">
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      Allow from all
    < /directory>
  ErrorLog "/private/var/log/apache2/local.mysite.dev.com-error_log"
< /VirtualHost>


5. Restart Apache

finally, restart the Apache
sudo apachectl restart
Open your browser the type the url (http://local.mysite.dev) --for example

How to run TextMate command in terminal on Mac OS

I have installed TextMate on my Mac,
i wanna edit some file in terminal using TextMate, googling that issue and found some tutorial
here's the step:
Open your Terminal and type
sudo ln -s /Applications/TextMate.app/Contents/SharedSupport/Support/bin/mate /usr/bin
now, you can call TextMat app with "mate" command:
mate /path/file_you_want_to_edit.txt
for more help, just type:
mate --help

Sunday, September 15, 2013

How to remove rails uninstalled in gem list

I have uninstalled the rails old version but still list when i type "gem list"
Just type on your terminal:
sudo gem cleanup