Internet development on a Mac

The best way to do internet development is to set up your mac to do it all locally. PHP and MySQL are the most popular tools for internet development, and they will be the focus of this article. There are many sites telling you how to install these, but most require compilation and other words you would rather not hear. I have personally used the installers described in this article on both a ppc Powerbook and on an intel MacBook, and they both worked without problems.

Start the web server

The webserver is already installed on all Macs, and it is just waiting for you to start it. Go to ‘System Preferences’, select ‘Sharing’, and check ‘Personal Web Sharing’. Your Apache web server is now running. You can find the site for your computer at http://localhost/, and the site for your own user account at http://localhost/~username/. The actual files for your web server are stored under /Library/WebServer/Documents/, and the files for each user account under /Users/username/Sites/, or simply ~/Sites/.

Install scripting support

You need support for the scripting language PHP to make your pages dynamic. The installer for PHP is found at entropy.ch. This installer is simple and straight forward. Type “httpd -V” in the terminal to see your Apache version so that you ‘re sure to download the right package. There are many resources for learning PHP, and www.php.net is great for finding examples and looking up syntax.

Install a database

The free MySQL database works really well together with PHP. This installer is as simple as the php installer. It is found at mysql.com (both ppc and intel). The installer also includes a control panel for starting and stopping the server, which is nice if you don’t like the terminal. This installation is also recommended by Apple. Entropy.ch also has installation instructions for this installer.

Install database tools

With PHP and MySQL in place, you can install a great PHP based administration tool called phpMyAdmin. All you have to do is to download it, unzip it, and place it under your web directory and enter your database user name and password in the configuration file. You will want to use phpMyAdmin to set up dedicated users to secure your database.

OK so far?

I recently followed my own instructions on a new Mac Pro and ran into a problem at this point. It seems that you may get some problem connecting to the database after OS X version 10.4.4. If phpMyAdmin says “The server is not responding (or the local MySQL server’s socket is not correctly configured)“, here is the solution.

Get started

The reason I am promoting PHP and MySQL is the enormous amount of free applications, APIs and tutorials available. Some examples include WordPress (the blogging motor for this and most other blogs), phpBB for forums, jpGraph for server generated graphics, and many others.

Web 2.0

I have been messing around with javascript a few times myself with great frustration, and I can only take my hat off to all the people who have used it to created the wonderful things that have been appearing the last years. The beauty of this is that it is now all available to you as libraries, and you only need to install them and write very little code to use them. It is all built on AJAX / httprequest and DHTML. Start looking at Prototype, script.alicio.us and MochiKit. Many people are looking forward to the day Google Web Toolkit becomes available for OS X.

Pest control

Once you start playing around, you will want to monitor how your creations are performing, and remove annoying bugs that are bound to show up. The error messages that do not appear in the browser mostly end up in the Console application. You find it under /Applications/Utilities/Console. The ones you will be interested in are Console.log and /var/log/: httpd: error_log and access_log.

Other alternatives

There are several other great tools for internet development out there. Ruby on Rails is quickly gaining popularity, and is definitively worth installing and looking into. It gets great reviews for letting you quickly create advanced services with very little code. You will also find a lot of information about these and other standards for internet development on OS X in Apples developer pages

Make your site available

While developing locally is very nice, you probably want the world to see all the great stuff you have created. Now that you are up and running, you will want to have the same amount of control over your site on a remote server as you do locally. Shop around until you find a web hotel that provides the server technology you have chosen to use locally. I personally use Surftown because it supports PHP and MySQL – and it is dead cheap, which is also nice :-) If you are using a web editor like Dreamweaver, you can use it to publish your local site on any server with an ftp account. If you are the hand coding type, you can use an ftp program like interarchy to upload your site.

Make your site accessible

The Mac may now be the best platform for internet development, but it is still far from the most used platform. If you start publishing your site, I seriously recommend that you test your design to make it work on all the major platforms and browsers.

Am I missing something?

Please use the comment feature below to remind me of important stuff I have forgotten. I will be updating this article to keep it all in one place.

Last updated friday, june 23.

6 Responses to “Internet development on a Mac”

  1. Brandon Says:

    The article has a good start, but it could use some more information or follow up posts. Things like Ruby and JSP as well as other databases options.

    Maybe just a giant link post with all the different web development tools for OS X? I dunno.

  2. herr klein Says:

    You are so right! I got a similar comment at digg.com, so I realize that this article was not thorough enough. An update will follow soon!

  3. admin Says:

    I have just added a major update, but this is a large area to cover, so please comment on anything I might have left out.

  4. Troy Says:

    Instead og jumping through all these hoops installing PHP and MySQL. I suggest you take a look at http://www.MAMP.info

  5. herr klein Says:

    Thanks for the tip, Troy. If this works it will make life a lot easier. I will look into it when I install a fresh system after Leopard is released.

  6. sopitikoj Says:

    Hi

    Hi! I like your site. Thanks for more interesting information. I wish good luck to you. Thanks!

    Bye

Leave a Reply