My last post was for all users, technical and non. This post is for the techies who know me, and are switching. Some are coming from Windows, some from Linux, some are designers who need to do some local development. So, I’ll try to keep this post as simple as possible, and perhaps more like a tutorial, where you can “copy and paste” commands and files.
If you’re going to be doing any kind of web development, chances are you’ll be deploying to a linux/unix server. I don’t know anything about Windows or IIS, so ignore this post if you’re looking for IIS help. I’m also assuming basic level of knowledge with how to find and edit files either via Finder, or via Terminal. For the non unix folks ~ for the rest of the article, means “Your home directory” . Your home directory is usually /Users/yourusername
Security Caveat
If you’re doing this on a laptop, please keep your company, or your clients security and confidentiality in mind. Disable auto login, use strong passwords, enable computer locking via Keychain.
I use these settings as a base. You can and should do a little more, but that’s not the focus of this post.
Things you’ll need
- XAMPP I prefer it over MAMP, because it seems to get upgraded faster, so the chances of a more recent PHP version are higher. Of course, for the uber nerds, you can get Macports, or Fink. If you’re comfortable, you can even install the Dev Tools CD, get GCC, and compile things yourself, something I used to do, but I no longer need the cutting edge.
- When I feel like getting cutting edge, I do install Vmware Fusion , turn on a Linux image, and have fun.
- Expandrive This is more for production, and remote servers, but I find this tool ridiculously handy. It’s better than the free variant of Macfuse, so it’s worth the money. Here’s how it’s better: the way to manage the drives is simpler, and reconnects to remote drives are more stable than the free sshfs variant.
- You can get MAMP and MAMP Pro MAMP Pro is worth the upgrade, if you decide to get MAMP.
- MySQL If you need MySQL 5.1, or for some reason 4 or 3, you need to go get it yourself, but XAMPP offers MySQL 5.0 by default
- Textmate An excellent editor if you don’t like vim/emacs.
- MacVim This is gVim for mac, with all the mac keyboard bindings, and the power of vim. (this is subjective: and the ease of vim). I’ve replaced the default vim, with this for my personal use
- Subversion 1.5 By default, OS X comes with SVN 1.4, some of my repositories have been upgraded to 1.5 so I needed to upgrade
- Git I’ve been playing on some projects which aren’t live, but merely proof of concepts, and I decided to learn git, with those projects. I’m really digging it, though I’m still struggling with Braid and getting it to do things like SVN Externals.
- Versions App This is a nice GUI for SVN, if you’re into GUIs
Setting up your Shell
Most of these things will go into ~/.bash_profile
Set your editors
Open up ~/.bash_profile in your favorite editor, and add the following lines
export SVN_EDITOR=’vim’
export EDITOR=’vim’
Of course, you can replace vim, with emacs, pico, nano, or if you hate your life, ed.
Change your paths
Since we’ve downloaded XAMPP, macvim, Subversion and Git, we need to make sure the newer version of these apps is available to us.
PATH=/usr/local/git/bin:/opt/local/bin:/usr/local/mysql/bin:$HOME/bin:$PATH
PATH=$PATH:/Applications/xampp/xamppfiles/bin:/opt/subversion/bin
I prefer to move the older binaries out of the way.
Open a new shell and type which php , or which svn
if you see things like /usr/bin/php or /usr/bin/svn, it means you’re still using the older versions. So do the following: (# bash represents your bash prompt, not a comment)
# cd /usr/bin
# sudo mkdir old
# sudo mv php* old
# sudo mv svn* old
You need to do some other things with Macvim, email me if their install instructions aren’t clear to you.
Setup your virtual hosts, and hosts file
Since you’re doing web development, you need to setup apache, and a means to access the virtual hosts on your laptop. Since you’re using XAMPP, you need to make sure that the built in Apache is not turned on. Go to System Preferences -> Sharing and make sure Web Sharing is not checked
The easy, but expensive way
You can download VirtualHost X and manage your virtual hosts with that, but the app is fairly basic, you still need to know your custom directives, if you want to do anything advanced. What’s nice is that it edits your /etc/hosts file for you, so it’s all done in one step. It’s not as advanced as MAMP Pro. But, it’s fairly straightforward and flexible as a GUI.
The somewhat harder, but cheaper way
Since we’re using XAMPP, you need to do the following:
# sudo vim /Applications/xampp/etc/httpd.conf : and uncomment the line asking for httpd-vhosts.conf
# sudo vim /Applications/xampp/etc/extra/httpd-vhosts.conf
Here you can create your own virtual hosts. I use a naming convention of laptop.domain.com, which always points to 127.0.0.1. You could edit your Name servers and add that record, but then it doesn’t work if you don’t have an internet connection. So, I prefer editing my /etc/hosts file.
Example Virtual Host Configuration
NameVirtualHost *:80
#Local Symfony installation for website
< VirtualHost *>
ServerName “laptop.example.com”
DocumentRoot “/Users/vluther/websites/example/web”
<Directory /Users/vluther/websites/example/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Alias /sf /Users/vluther/websites/example/lib/vendor/symfony/data/web/sfErrorLog /var/log/apache2/example_error.log
CustomLog /var/log/apache2/example_access.log combined
</VirtualHost>
Notice I keep the logs in /var/log/apache2/. This is so I don’t need to mess with the log rotation scripts of OS X.
Example /etc/hosts file
127.0.0.1 laptop.example.com example
127.0.0.1 laptop.example2.com example2
In conclusion
I’m not going into details of how you create your local working copies with git, svn, or finder. If you really need help with that, email me, or ping me on twitter
If you’re using Django, or RoR, you can skip most of the apache configuration options, and just use the built in web servers that come with the frameworks. For production/stage testing I recommend installing linux on a vmware image, and then messing with FastCGI/mod_python for Django or whatever you need to do with ruby.
By no means is this supposed to be the only way you do things, there’s more than one way to skin this cat. Please share your insights and methods in the comments below.
Nice detailed description, but won’t you run into case sensitivity (filenames e.g.) problems at some point, or at least, risk running into those?
Thats what I sometimes had with developing on Windows, and afaik, OS X’ default filesystem has the same problem.
Nice detailed description, but won’t you run into case sensitivity (filenames e.g.) problems at some point, or at least, risk running into those?
Thats what I sometimes had with developing on Windows, and afaik, OS X’ default filesystem has the same problem.
Thanks Maarten,
Case sensitivity does come into play at times, I’ve seen this issue with many SVN repositories that have File.php and file.php. Unfortunately apart from re-installing OSX with case sensitivity enabled in the FS, the only other thing I can recommend is make sure all file names are lower case.
That’s what I do. :/
Thanks Maarten,
Case sensitivity does come into play at times, I’ve seen this issue with many SVN repositories that have File.php and file.php. Unfortunately apart from re-installing OSX with case sensitivity enabled in the FS, the only other thing I can recommend is make sure all file names are lower case.
That’s what I do. :/
[...] here to read the rest: Using your Mac as a local web development environment. Related ArticlesBookmarksTags PHP Development Tools – Keeping it Simple and Mostly Fre If [...]
Case-sensitive filesystem with OSX causes trouble with various apps that have things wrong internally; there’s a few although one specific one I remember is the Adobe suite. It won’t be able to find some of its own libraries as the case in the binary is different from the filename on disk. Pretty stupid, of course.
I think it’d be grand it Apple pushed its friendly vendors to clean up their mess, as I’d love to have the case-sensitive filesystem. It also prevents quirks with the *nix toolset which kinda expects this anyway but “kinda” copes with the case-insensitivity. It’s not perfect.
Case-sensitive filesystem with OSX causes trouble with various apps that have things wrong internally; there’s a few although one specific one I remember is the Adobe suite. It won’t be able to find some of its own libraries as the case in the binary is different from the filename on disk. Pretty stupid, of course.
I think it’d be grand it Apple pushed its friendly vendors to clean up their mess, as I’d love to have the case-sensitive filesystem. It also prevents quirks with the *nix toolset which kinda expects this anyway but “kinda” copes with the case-insensitivity. It’s not perfect.
Thanks for that Arjen, I wasn’t aware of such issues with OS X and case sensitivity. I personally haven’t use an Adobe product besides PDF reader in many years, so I had no clue. Last time I used Adobe, was Photoshop 3, or System 7.5.
.
Thanks for that Arjen, I wasn’t aware of such issues with OS X and case sensitivity. I personally haven’t use an Adobe product besides PDF reader in many years, so I had no clue. Last time I used Adobe, was Photoshop 3, or System 7.5.
.
[...] Read more: Using your Mac as a local web development environment. [...]
Interesting post! I’m also using an iMac with OS X 10.5.6 as development platform and I’m using MacPorts for getting PHP, Apache, and MySQL.
Interesting post! I’m also using an iMac with OS X 10.5.6 as development platform and I’m using MacPorts for getting PHP, Apache, and MySQL.
If you are using TextMate, you have got to set up the mate command. It’ll change your life. It can be used from Terminal to open any file or directory with TextMate. It can also be used as your external editor for SVN commit messages.
Here’s how to set it up:
http://manual.macromates.com/en/using_textmate_from_terminal.html
If you are using TextMate, you have got to set up the mate command. It’ll change your life. It can be used from Terminal to open any file or directory with TextMate. It can also be used as your external editor for SVN commit messages.
Here’s how to set it up:
http://manual.macromates.com/en/using_textmate_from_terminal.html
Moving old binaries…not always a good thing as the OS might rely on them. Instead put the new binaries in /usr/local/bin or /opt/local/bin and put that first in your PATH.
Moving old binaries…not always a good thing as the OS might rely on them. Instead put the new binaries in /usr/local/bin or /opt/local/bin and put that first in your PATH.
Going for a cheaper and equally robust solution, I’d prefer macfusion to expandrive and smultron to textmate. I calculate that this reduces the cost of the development environment to 0
Going for a cheaper and equally robust solution, I’d prefer macfusion to expandrive and smultron to textmate. I calculate that this reduces the cost of the development environment to 0
Expandrive is nice tool, and for a while I played with. But I don’t do it anymore because is very slow. If the developers could make some sort of “buffer” would be nice.
) is blocking until the save is done. So I prefer Forklift as file manager, with my remote places opened by it.
The problem is the editor( Textmate
Expandrive is nice tool, and for a while I played with. But I don’t do it anymore because is very slow. If the developers could make some sort of “buffer” would be nice.
) is blocking until the save is done. So I prefer Forklift as file manager, with my remote places opened by it.
The problem is the editor( Textmate
rborn,
Regarding your issue with Expandrive and Textmate, did you try Remate? http://blog.expandrive.com/2008/08/08/expandrivetextmateremate/
I’m going to check out forklift as well.
rborn,
Regarding your issue with Expandrive and Textmate, did you try Remate? http://blog.expandrive.com/2008/08/08/expandrivetextmateremate/
I’m going to check out forklift as well.
Using localhost is all nice and good, but what if you also want to be able to have a VM guest access the same sites for testing? I’m on a laptop and am running my own DNS server on the OS X side but when there is no network connection, OS X doesn’t let me access the local DNS server so all of the internal domain names I’ve set up won’t resolve, even though going by IP address (e.g., 192.168.4.2) works fine. Unfortunately, this doesn’t work since I use name-based hosting for my dev sites.
Help?
Using localhost is all nice and good, but what if you also want to be able to have a VM guest access the same sites for testing? I’m on a laptop and am running my own DNS server on the OS X side but when there is no network connection, OS X doesn’t let me access the local DNS server so all of the internal domain names I’ve set up won’t resolve, even though going by IP address (e.g., 192.168.4.2) works fine. Unfortunately, this doesn’t work since I use name-based hosting for my dev sites.
Help?
rborn – Check back in the next week or two, we’re putting ExpanDrive 2.0 into testing which has dramatic performance increases in this area. MUCH faster.
rborn – Check back in the next week or two, we’re putting ExpanDrive 2.0 into testing which has dramatic performance increases in this area. MUCH faster.
Great Walkthrough, you’ve done some things differently here than I do, so I am going to bookmark this and try it this way next time.
@ Dereck, I have never run into case sensitive issues by following proper svn workflows and creating my projects correctly. I do *always* create a ‘developer’ account, and install my stacks (like MAMP, ColdFusion, etc) as standalone environments.
@ Johanna and rborn, I fully agree on ‘mate’ its great, I haven’t run into issues with the expandrive but just started using it with mate about a week ago, but being able to open a remote file in a text editor you like, well, as MC says, ‘priceless’. you just have to be very careful about getting in the habit of modifying files on the remote (usually production server) and not following your svn workflow. Jesus saves, and so should you.
@ Jeff, I’m looking forward to the 2.0 version, you have just made another sale.
@ Vid, two other tools: Coda and Sequel Pro. Sequel Pro, I use instead of PHPMyAdmin for managing local and remote mySQL dbs. A very nice GUI, and free. I use Coda, esp. coding ColdFusion (auto text completion when you get tired of typing ‘cfoutput’ ), or are looking for a more interactive CSS tool it is well worth the money. It is quite easy to setup development (local) and production (remote) versions of your project, keeps track of changed files and uses a built in version of Transmit to make the sftp process one click. It also has a small toolkit available to hook in with svn. I like it more than TextMate for some things (split pane live previews of css and server-language changes, built in terminal, and code collaboration across bonjour). For other languages, eg Rails and text editing funtions, TextMate has such a powerful set of Bundles, you just cant beat it. Also, the TextMate subversion bundle is more than adequate for most users, Versions is a fantastic program, but more than what most people need.
Re: the development process,
another great tool is the stacks available at Bitnami they have one click standalone stacks for nearly every production environment, and if you want to have a stack dedicated to a specific CMS, like a Joomla install running on its own virtual server, this is the place to go. Another use: you dont have to mess with the local install of apache that comes with leopard if you want to test on an apache2 environment, just install their MAMMP stack and go to the localhost port specified. this even works to a request outside the firewall. As example, I setup a Redmine (RoR project mgnt app) stack with Bitnami a few weeks ago. then setup my routing through my firewall and the client was able to go to a temp address (myExternalIP:redminePort) and see his site in development. the firewall took care of routing to the correct machine, and the stack took care of serving those requests.
Second,
learn subversion on the command line. its much easier, most actions can be done with one command line entry, and you almost always have a terminal window open anyway, right? A simple
svn up *is all you need to checkout the latest versions for every checkout in yourpwdFinally, for you windows switchers the coolest thing, ever? If you made it this far down the wall, you probably don’t need a push, but just in case. Well…
drag and drop paths into Terminal
Great Walkthrough, you’ve done some things differently here than I do, so I am going to bookmark this and try it this way next time.
@ Dereck, I have never run into case sensitive issues by following proper svn workflows and creating my projects correctly. I do *always* create a ‘developer’ account, and install my stacks (like MAMP, ColdFusion, etc) as standalone environments.
@ Johanna and rborn, I fully agree on ‘mate’ its great, I haven’t run into issues with the expandrive but just started using it with mate about a week ago, but being able to open a remote file in a text editor you like, well, as MC says, ‘priceless’. you just have to be very careful about getting in the habit of modifying files on the remote (usually production server) and not following your svn workflow. Jesus saves, and so should you.
@ Jeff, I’m looking forward to the 2.0 version, you have just made another sale.
@ Vid, two other tools: Coda and Sequel Pro. Sequel Pro, I use instead of PHPMyAdmin for managing local and remote mySQL dbs. A very nice GUI, and free. I use Coda, esp. coding ColdFusion (auto text completion when you get tired of typing ‘cfoutput’ ), or are looking for a more interactive CSS tool it is well worth the money. It is quite easy to setup development (local) and production (remote) versions of your project, keeps track of changed files and uses a built in version of Transmit to make the sftp process one click. It also has a small toolkit available to hook in with svn. I like it more than TextMate for some things (split pane live previews of css and server-language changes, built in terminal, and code collaboration across bonjour). For other languages, eg Rails and text editing funtions, TextMate has such a powerful set of Bundles, you just cant beat it. Also, the TextMate subversion bundle is more than adequate for most users, Versions is a fantastic program, but more than what most people need.
Re: the development process,
another great tool is the stacks available at Bitnami they have one click standalone stacks for nearly every production environment, and if you want to have a stack dedicated to a specific CMS, like a Joomla install running on its own virtual server, this is the place to go. Another use: you dont have to mess with the local install of apache that comes with leopard if you want to test on an apache2 environment, just install their MAMMP stack and go to the localhost port specified. this even works to a request outside the firewall. As example, I setup a Redmine (RoR project mgnt app) stack with Bitnami a few weeks ago. then setup my routing through my firewall and the client was able to go to a temp address (myExternalIP:redminePort) and see his site in development. the firewall took care of routing to the correct machine, and the stack took care of serving those requests.
Second,
learn subversion on the command line. its much easier, most actions can be done with one command line entry, and you almost always have a terminal window open anyway, right? A simple
svn up *is all you need to checkout the latest versions for every checkout in yourpwdFinally, for you windows switchers the coolest thing, ever? If you made it this far down the wall, you probably don’t need a push, but just in case. Well…
drag and drop paths into Terminal
Wow @Jed, your comment was almost as long as my blog post
. Great tips and tricks.
I’ve tried Coda, and I love their Panic sans font, so I actually use that font within ZDE and vim
.
One thing Coda is missing, or I’m doing it wrong, is the ability to autocomplete for classes you’ve included in your code. ZDE, Komodo etc allow for that, which is wonderful when working with APIs, and third party libraries.
Thanks for that tidbit about not editing files on production servers, I assumed most people knew that, but it’s always a good reminder
.
Lastly, the reason why I didn’t mention Sequel Pro yet, is because that’s for another blog post, and another presentation I’m working on, for DB Tools. I personally prefer Froq, but it’s been a while since I’ve tried Sequel Pro, I’ll try it again.
Wow @Jed, your comment was almost as long as my blog post
. Great tips and tricks.
I’ve tried Coda, and I love their Panic sans font, so I actually use that font within ZDE and vim
.
One thing Coda is missing, or I’m doing it wrong, is the ability to autocomplete for classes you’ve included in your code. ZDE, Komodo etc allow for that, which is wonderful when working with APIs, and third party libraries.
Thanks for that tidbit about not editing files on production servers, I assumed most people knew that, but it’s always a good reminder
.
Lastly, the reason why I didn’t mention Sequel Pro yet, is because that’s for another blog post, and another presentation I’m working on, for DB Tools. I personally prefer Froq, but it’s been a while since I’ve tried Sequel Pro, I’ll try it again.
Great writeup. I prefer to compile my own PHP, but one of the problems I’ve had with doing so on OSX is that OS updates will occasionally overwrite my PHP binaries, breaking functionality. I’ve resorted to VMs to get around this problem.
Do you know if the server in a box (XAMPP, MAMP, etc) handle the problem of the OS wanting to upgrade your installed software?
Great writeup. I prefer to compile my own PHP, but one of the problems I’ve had with doing so on OSX is that OS updates will occasionally overwrite my PHP binaries, breaking functionality. I’ve resorted to VMs to get around this problem.
Do you know if the server in a box (XAMPP, MAMP, etc) handle the problem of the OS wanting to upgrade your installed software?
nice post, thanks for sharing!
nice post, thanks for sharing!
Consider also Cornerstone as an alternative to Versions.
Consider also Cornerstone as an alternative to Versions.
Thanks for the reminder about Cornerstone Terry. I hadn’t mentioned it before due to it having SVN built into it, and the version being 1.4. Nice to see they have both 1.5 and 1.4 now. Will have to try it again.
Thanks for the reminder about Cornerstone Terry. I hadn’t mentioned it before due to it having SVN built into it, and the version being 1.4. Nice to see they have both 1.5 and 1.4 now. Will have to try it again.
Hmm, didn’t see you were looking at SQL clients also (or future blog post). Consider also SQL Developer from Oracle. It’s free and I’m told it interfaces with MySQL (though I don’t know, I use it for Oracle development).
Hmm, didn’t see you were looking at SQL clients also (or future blog post). Consider also SQL Developer from Oracle. It’s free and I’m told it interfaces with MySQL (though I don’t know, I use it for Oracle development).
How to create a web development environment using Apache,PHP and MySQL.
making use of Linux Vitual Server(LVS).
NB! How to install and to configure this environment
Hint!! (By making use of Nagios to monitor all the nodes on the network)
(Nagios must run on the web server)
( DNS must be setup for this environment)
(Each node must have a domain name)
How to create a web development environment using Apache,PHP and MySQL.
making use of Linux Vitual Server(LVS).
NB! How to install and to configure this environment
Hint!! (By making use of Nagios to monitor all the nodes on the network)
(Nagios must run on the web server)
( DNS must be setup for this environment)
(Each node must have a domain name)
how to create a web development environment using Apache,PHP,MySQL making use of Linux Vitual Server(LVS) to ensure redundancy and that the database servers run with replication.
how to create a web development environment using Apache,PHP,MySQL making use of Linux Vitual Server(LVS) to ensure redundancy and that the database servers run with replication.
can you please send me the solution on how How to create a web development environment using Apache,PHP and MySQL.
making use of Linux Vitual Server(LVS).
NB! How to install and to configure this environment
Hint!! (By making use of Nagios to monitor all the nodes on the network)
(Nagios must run on the web server)
( DNS must be setup for this environment)
(Each node must have a domain name)
can you please send me the solution on how How to create a web development environment using Apache,PHP and MySQL.
making use of Linux Vitual Server(LVS).
NB! How to install and to configure this environment
Hint!! (By making use of Nagios to monitor all the nodes on the network)
(Nagios must run on the web server)
( DNS must be setup for this environment)
(Each node must have a domain name)
can you please send me the solution on how How to create a web development environment using Apache,PHP and MySQL.
making use of Linux Vitual Server(LVS).
NB! How to install and to configure this environment
Hint!! (By making use of Nagios to monitor all the nodes on the network)
(Nagios must run on the web server)
( DNS must be setup for this environment)
(Each node must have a domain name)
can you please send me the solution on how How to create a web development environment using Apache,PHP and MySQL.
making use of Linux Vitual Server(LVS).
NB! How to install and to configure this environment
Hint!! (By making use of Nagios to monitor all the nodes on the network)
(Nagios must run on the web server)
( DNS must be setup for this environment)
(Each node must have a domain name)
It is really a nice article … i really like it.. great work.
Promatics as a web 2.0 development company can make your traditional website or a web application extremely powerful in the sense it will be exposed to users via various channels making your ROI faster and cheaper. Web 2.0 is a collection of approaches, which involves converging the users and information at a rapid pace. The tools used in web 2.0 help you to collaborate, distribute and market the information which can extend the exposure of your product or service and can lead to greater returns.
An interesting read….
It’s a very informative article, and relevant to all freelance web developers still amassing work experience. Formal training of any form can help freelance web developers to beef up their resume.
It’s a very informative article, and relevant to all freelance web developers still amassing work experience. Formal training of any form can help freelance web developers to beef up their resume.