Roy's Rants | Things I've found out

Jul/10

13

Mac OS X 10.6.4 and Macfusion

I love Macfusion.  At work we don’t have samba installed on our dev servers and duplicating the environment on my own development machine is yet unacheivable.  So Macfusion is a godsend.  Macfusion allows you create a ssh mount.  So Macfusion allows you to mount a directory of a remote machine just like you would a network drive over SSH.  However, when I updated my Snow Leopard with the latest update to 10.6.4, Macfusion somehow quite working.  Fortunately, I was able to find the following link: http://rackerhacker.com/2009/08/28/fix-macfusion-on-snow-leopard/ which details how to get it working again.  It worked for me!  Hopefully if you are having the same problem, it will work for you too!

· ·

When you start developing a website the first thing that you might do is go to godaddy and register your domain, then you find a place to host your site and so on and so forth.  However, if you have a Mac, you don’t need to start there.  You can start serving up your new website on your own machine first.  Then when you are finished and you have all the kinks worked out you and worry about registering the domain and finding a hosting provider and all that jazz.  Developing locally on your own machine is so nice.  So this tutorial will help us set up our Mac so that it can act as a web server.  Now Macs, already come with apache and php.  However, I don’t like to use that pre installed stuff.  I actually like to use the Zend Community Server.  It is a great package and it will install apache, php, and mysql all together.  It will also already be setup to debug with Zend Studio.  The ability to debug your web applications is a must if you ask me.

Zend Community Server

Download the zend community server from the Zend website.
As of this publication I downloaded: ZendServer-CE-php-5.3.2-5.0.1.dmg
Double click on the dmg to mount and open up the contents.  Double click on the ZendServer.pkg and run the installer.
Now Apache, PHP 5.3 and Mysql are installed.  However, we need to configure some things so that we can use them.
zend installs all of it’s packages in the /usr/local/zend directory, so apache is in /usr/local/zend/apache2, mysql is in /usr/local/zend/mysql
Most of your executables that you will use, execept mysql, are in the /usr/local/zend/bin directory
So if you want to use apache, php, or mysql from the command line you will one to add the following to your /etc/profile

PATH=$PATH:/usr/local/zend/bin

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/zend/lib
export VISUAL=/usr/bin/nano
export EDITOR=/usr/bin/nano

alias mysql=/usr/local/zend/mysql/bin/mysql
alias mysqladmin=/usr/local/zend/mysql/bin/mysqladmin
alias mysqldump=/usr/local/zend/mysql/bin/mysqldump

Now we need to edit apache conf file so that it will be easy to run.  Edit /usr/local/zend/apache2/conf/httpd.conf

Change the zend default of listening on port 10088 to listening on port 80

old line: Listen 10088
new line: Listen 80

Change the document root from inside the zend apache folder to somewhere more convenient.  I like to use the Sites directory under my user account directory.  You can change it to where ever you want.  Of course, your name is probably not Roy so don’t just expect copying and pasting to work for you.

old line: DocumentRoot “/usr/local/zend/apache2/htdocs”
new line: DocumentRoot “/Users/ROY/Sites”

Add Directory Permissions to your new DocumentRoot by changing the “<Directory>” listing:

old line: <Directory “/usr/local/zend/apache2/htdocs“>
new line: <Directory “/Users/rmerrill/Sites”>

Add other extensions to act as index files instead of just index.html

<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>

Un-comment the Virtual hosts Include directive

old line: #Include conf/extra/httpd-vhosts.conf
new line: Include conf/extra/httpd-vhosts.conf

Now save your changes.  Now let’s update the httpd-vhosts.conf file.  This file will tell apache that we are going to have virtual hosts and where to look for them.  Edit /usr/local/zend/apache2/conf/extra/httpd-vhosts.conf

Change the NameVirtualHost from looking on port 10088 to port 80

old line: NameVirtualHost *:10088
new line: NameVirtualHost *:80

Remove the VirtualHost examples and add an include directive that tells apache to look in the vhosts directory under your Sites folder for any virtual host conf files:

new line: Include /Users/Roy/Sites/vhosts/

Now save your changes.

We are set up to start developing locally.  For the rest of my tutorial I will use the domain roysrockets.com as site that I am developing.

Now that I have my server set up, I want to setup the site that I am developing on my local machine.  Whenever I am working on a website, I like my local version to use the extension lcl instead of the the real extension.  That way if I am making updates on my local machine I can check the live site by using the real domain and the dev site by using the local domain.  So in the example of roysrockets.com, I would use the domain roysrockets.lcl for my local site and roysrockets.com for my live site.

In order to make our development machine to look locally for our domain instead of out on the web, we need to add our local domain to the /etc/hosts file:

new lines:

127.0.0.1  roysrockets.lcl
127.0.0.1  www.roysrockets.lcl

Now we need to add a configuration file to our vhosts directory so that apache will know where to look for your roysrockets.lcl content.  Create a file called ‘roysrockets.conf’ in the /Users/Roy/Sites/vhosts/ directory:

<VirtualHost *:80>
ServerAdmin roy@withinmysite.com
DocumentRoot /Users/Roy/Sites/roysrockets.com
ServerName roysrockets.lcl
ServerAlias www.roysrockets.lcl
ErrorLog logs/roysrockets.lcl-error_log
CustomLog logs/roysrockets.lcl-access_log common

<Directory “/Users/Roy/Sites/roysrockets.com”>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Save the file and restart apache.  Remember that zend’s apache files are in /usr/local/zend.  If you just do sudo apachectl restart then you will use the apache version that comes with Mac and you won’t get the desired results.  So you need to make sure that you do: sudo /usr/local/zend/bin/apachectl restart.

So there we have it.  Now we just create the folder roysrockets.com in the /Users/Roy/Sites/ folder and start adding web pages.  When we wont to look at what we have created so far, we just open up our browser and go to: http://www.roysrockets.lcl

· · · · ·

I use a mac for my desktop computer so I am going to start from there.  Now if you use windows or something else, that is okay.  You will just have to find your own way of getting a the debian iso on to a CD.

Make an install disk of Debian

  1. Download a iso of Debian.  Go to: http://www.debian.org/distrib/netinst and click on the ‘Small CDs’ link.  From there you will want to click on the link of your computer’s cpu.  If you have a intel or athlon xp cpu then click on the i386.  If you have a Athlon64, then click on the amd64.  That will initiate the iso download.
  2. Once the iso is downloaded,  launch the Disk Utility program on your mac.  click Command + spacebar and then type in Disk Utility.
  3. Insert a blank disc into your cd/dvd drive
  4. In the Disk utility program, click ‘File’ and select ‘Open Disk Image’.  That will open up a ‘Select Image to Attach’ window.  In that window, navigate to where you downloaded the iso to, usually the ‘Downloads’ folder.  Then select the iso file and click on the ‘Open’ button.
  5. Now in the Disk Utility program, select the iso image in the left hand menu and click on the ‘Burn’ icon in the top menu.  A pop-up window will appear and click the ‘burn’ button again.
  6. Wait for the cd to be burned.

Install Debian on your computer

  1. Start the computer up and continually click on the ‘delete’ key so that the bios screen comes up.  Make sure that the boot options show that booting from a CD/DVD drive has first priority.  Save and Exit.
  2. Insert the debian install disk and start up the computer.
  3. Follow the install setup wizard until you get to the partition disks section.
  4. select ‘Manual’ partitioning of disks.
  5. delete any existing pratitions.
  6. First, let’s set up the ’swap’ partition.  Select the free space and click ‘continue’.  Select ‘Create a new partition’ and click ‘continue’.  Enter the size of the partition.  I usually do twice or three times as much ram available, then click ‘continue’.  Select ‘Primary’ then click ‘continue’.  Now when it starts to create a partition by default it uses it as a ext3 journaling file system.  We want a swap so we need to go up and select the ‘Use as’ row and hit ‘return’.  Now scroll down and select ’swap area’ and hit ‘return’.  Now select ‘Done setting up the partition’ and click ‘continue’
  7. Now we need to create the root partition.  Duplicate the above steps accept use the remaining disk space and make sure it has the ‘bootable’ flag set.
  8. Now that we have created the partitions we need to write them to disk.  Select ‘Finish partitioning and write changes to disk’ and then click ‘Continue’.  Review your changes to make sure that is what you really want, then select ‘Yes’ and click ‘Continue’.
  9. Wait for the partitions to be writen out, then the base system to install…  Now unselect the desktop environment checkbox, unless you want it, and click ‘Install’ to finish.

Configure debian with the server software

  1. Apache & PHP
    1. setup the environment:
    2. 1. Define a repository by opening the following file: /etc/apt/sources.list and adding the line:

      deb http://repos.zend.com/zend-server/deb server non-free

      2. Add Zend’s repository public key by running:

      # wget http://repos.zend.com/deb/zend.key -O- |apt-key add -

      If you are using sudo to run each command the next command requires using sudo following the ‘|’ (pipe) symbol as follows:

      # wget http://repos.zend.com/deb/zend.key -O- | sudo apt-key add -

      3. To synchronize with Zend’s repository run:

      # aptitude update

    3. install zend community server:
    4. To install Zend Server Community Edition with PHP 5.2 run:

      # aptitude install zend-server-ce-php-5.2

      To install Zend Server Community Edition with PHP 5.3 run:

      # aptitude install zend-server-ce-php-5.3

    5. configure server for all users:
    6. Zend Server is now installed in the /usr/local/zend directory.  The php, pear, pecl, and apachectl binaries are in the bin directory.  So you will probably want to put them into your PATH.

      To add the /usr/local/zend/bin directory to your $PATH environment variable for all users:

      Log in as root or use sudo to execute the following commands.
      Using a text editor, open /etc/profile.
      Add the following lines to the end of the file:

      PATH=$PATH:/usr/local/zend/bin

      LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/zend/lib

      Save the file.

      In order for this to take effect, close and reopen your shell or run the following command:

      source /etc/profile

      You can now run the PHP binary provided by Zend Server Community Edition without typing its full path.

  2. Mysql
    1. #apt-get install mysql-server
  3. SSH Server
    1. #apt-get install openssh-server

Extra configurations

You can add some extra color and stuff to the prompt by adding the following to /etc/profile:

export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
export VISUAL=/usr/bin/nano
export EDITOR=/usr/bin/nano

No tags

Theme Design by devolux.nh2.me