This is just a quick and dirty guide to setting a development environment for PHP on Mac OS X 10.6.2, but will also work for Leopard (10.5.x) as well. There are a few things that are essential to setting up a dev environment for PHP. Mainly, installing PHP & MySQL and having a great IDE and perhaps a PHP framework to start from.
- Installing PHP & MySQL – There are several ways to install these packages on a Mac. You can build the source code, download installers for each or download a development bundle that already has everything setup. If you are just using your local machine to develop on then you probably don’t need to update the PHP version on your Mac or install MySQL to the Mac’s bin directory. There are much easier options. They aren’t secure enough for production machines, but for your local development they will do just fine. The easiest one is BitNami stacks. BitNami provides a wide range of application stacks such as Wordpress, Joomla, and Drupal to name a few. It also provides Infrastructure Stacks. These are stacks like MAMP, WAMP, LAMP, etc. Basically, this is a base install for M(ac) A(pache) M(ySQL)P(HP), or Windows Apache MySQL & PHP, etc.
- Download MAMP ~63MB. If you are developing plugins or themes for Wordpress or one of their other application stacks then you might just skip this install and download that application stack.
- Next we need to run the bitnami-mampstack-1.2…installer.app.
- You will just be prompted for the install location and the root password. The only requirement is that the password is more than 6 characters.
- When the installer is done you should now see that your install was a success. Your web-browser will open to page http://127.0.0.1:8080/ This is your localhost address.
- Next step is to locate where these files are coming from. I used the default install which places all files in /Applications/mampstack-1.2-0/ . The page you see on your success page is coming from /Applications/mampstack-1.2-0/apache2/htdocs/. You can remove all the files from this folder and place your PHP scripts here instead. If you haven’t used a PHP framework yet, I suggest you try out CodeIgniter. It’s simple to use and there is a lot of documentation and support online.
- Install CodeIgniter – Simply download Codeigniter from here. Extract the contents of CodeIgniter_xx to the folder /Applications/mampstack-1.2-0/apache2/htdocs/. Also, it’s best practice to move the application folder from out within the system folder and to the base or the htdocs/ folder. (Command double-click the system folder to open in a new finder window.)
-

- Next it’s time to install a free PHP IDE. Take a pick from my recent article on the top 5 free PHP IDEs on MAC. I chose to use NetBeans due to the great features, free, syntax highlighting, and code completion for libraries such as CodeIgniter.
- Just a few quick tips. To access your phpMyAdmin you can goto the link http://127.0.0.1:8080/phpmyadmin/. Here the username is: administrator and the password is the one you used durning the install.
- Configure CodeIgniter – With NetBeans choose New Project -> PHP Application with Existing Sources -> Sources folder: /Applications/mampstack-1.2-0/apache2/htdocs ->Project Name: Whatever you want. -> Run As: Local Web Site -> Project URL: http://127.0.0.1:8080/ -> Index File: index.php .
- Now everything should be setup. Just a few tweaks to configure the database and index file. Open application/config/ and enter in your database credentials. Next open config and change your base url to http://127.0.0.1:8080/.
That’s it you can now visit http://127.0.0.1:8080/ and you should see your wonderful new site. I hope this helps clear up some questions about getting started with Mac Apache MySQL PHP. If you have any further questions please don’t hesitate to ask in the comments below. TRHFUVMUP9CQ



November 24th, 2009 @ admin
0