Learning PHP on the Mac

Discussion in 'Web Design and Development' started by ed45, Apr 23, 2014.

  1. ed45 macrumors newbie

    Joined:
    Mar 9, 2013
    #1
    I'd like to learn PHP on the Mac. Up until a decade ago, I used to do a fair amount of programming, mainly online and in a UNIX environment - so I'm a dinosaur in that regard. I knew a little PHP, and I'd like to expand on that now. I'm trying to find a stable development environment for "beginners" that I can install on my late 2012 iMac, currently running OS X 10.8.5.

    I've considered MAMP, XAMPP, Ubuntu or Vagrant running on Virtual Box, using OS X's built-in Apache server, and even a Linux laptop from Dell or System76. At the moment, my iMac is my only functional computer, and I'm relatively new to the Mac, so I'm skittish about installing anything that could possibly render OS X unstable. Virtual Box sounded like the best solution until I started reading about people experiencing kernel panics on new Macs that wouldn't stop even after Virtual Box was uninstalled. I'm also wondering if upgrading to Mavericks when 10.9.3 is released would have any effect, positive or negative.

    Anyone have any thoughts or suggestions?
     
  2. firedept macrumors 603

    firedept

    Joined:
    Jul 8, 2011
    Location:
    Somewhere!
    #2
    I use MAMP Pro, but MAMP is fine and it is free. No need to run it in a virtual environment. I have been using it with Dreamweaver & Coda 2 for several years on various Macs that I have owned. MAMP is very stable and easy to set up.

    In all the years I have used it, I have never run into a problem on my Macs due to MAMP. MAMP would be all you need. You would not need to set up OS X's built-in Apache server as everything you need is included in MAMP.

    This is what I prefer and works well for me. Just my suggestion, but others forum members may have better suggestions.
     
  3. theluggage macrumors 68030

    Joined:
    Jul 29, 2011
    #3
    If in doubt, just make sure that you back up before you install anything...

    The only thing you're likely to break by enabling OSX's built-in PHP & Apache is the built-in Apache, which isn't critical unless you're running OSX server. OS X doesn't always have the latest versions... however, if you want to write stuff that may eventually end up being put on commercial webspace, its best not to use bleeding-edge PHP or Apache features anyway.

    However, MAMP is probably the best bet - if you're learning PHP then sooner or later you'll probably want to do database stuff, and MAMP includes MySQL.
     
  4. 960design macrumors 68020

    Joined:
    Apr 17, 2012
    Location:
    Destin, FL
    #4
    Yep, been prototyping many PHP sites on MAMP for many years on a Mac. MAMP should be a part of your PHP tool box for sure.
     
  5. thejadedmonkey macrumors 604

    thejadedmonkey

    Joined:
    May 28, 2005
    Location:
    Pa
    #5
    I use VirtualBox at work, every day, usually with 2 or 3 VM's up at once. It's rock solid on Maverics and has been since around the time 10.9.1 was released. Even before that though, it never causes any KPs, just messed with the network stack somewhat.

    Having said that, if you're looking to learn php, MAMP is the way to go. That'll get you started learning PHP fast. Going with a 'nix VM is only productive if you also want to learn 'nix administration, and even then there's a huge difference between being able to install a web server with apt-get and being a competent admin.

    /my 2¢
     
  6. ed45 thread starter macrumors newbie

    Joined:
    Mar 9, 2013
    #6
    Hey - thanks everybody for your suggestions! Although I did dabble in PHP, most of my online programming projects were written in Perl and database driven with MySQL, other than one ASP application.

    Sounds like MAMP is the way to go, and I'll consider trying Virtual Box when I've become more acclimated to the process.

    Thanks for the great feedback.
     
  7. elppa macrumors 68040

    elppa

    Joined:
    Nov 26, 2003
    #7
    I don't understand why you need Linux in a VM for development initially. For releasing to a production environment you will definitely get some performance gains out of running on a Linux distro (like CentOS or Debian), but for development the point is not so important.

    With this in mind you should be able to get up to speed fairly quickly on a Mac. There are a few differences, but OS X is just a capable as any other *nix operating system. In fact it is a bit more capable, because it has a decent selection of commercial software as well.

    You may find this link helpful:
    Setup your dev environment without annoying tools

    Good luck!
     
  8. ed45 thread starter macrumors newbie

    Joined:
    Mar 9, 2013
    #8
    I really don't need Linux. That was first suggested to me by a friend who's doing much more sophisticated work than I intend to do initially.

    I'm fairly settled on MAMP. As a Mac newbie, I'm not so much worried about the UNIX aspects of OS X as I am the non-UNIX aspects that are built around the kernel - which I don't want to muck up. In particular I've heard stories about modifications to the environment causing issues in subsequent OS X updates if the person making them doesn't completely know what he's doing (spotlight on me). Once I get more acclimated to OS X I may get more adventurous.

    Much appreciated!
     
  9. theluggage macrumors 68030

    Joined:
    Jul 29, 2011
    #9
    Since OSX 10.8, Apache and PHP are only used by OS X if you have OS X Server. You're unlikely to muck anything up by messing with them. On the other hand, there's no real advantage to using them - they tend to be out-of-date, you can't really add extra PHP modules etc.

    Using MAMP to start with makes sense - its not like its a one-way street and it keeps everything tucked up in an application bundle.

    If you start writing stuff seriously, Linux in a VM can be useful because you can tailor it to closely match your target server (e.g. by running the same Linux distro or tweaking the directory structure to match).
     
  10. typonaut macrumors member

    Joined:
    May 7, 2014
    #10
    Missing something?

    Perhaps I'm missing something, but Apache and PHP (and Python) are included in MacOS X. All you have to do to activate them are turn on web sharing and point your browser at http://127.0.0.1 (or http://localhost).

    If you want MySQL too you can just download the binary from MySQL, there's also a start/stop MySQL control panel to download, so you can control it from system prefs.

    If you want to get more up-to-date versions of any of these apps you can just download (compile if necessary) and install them - it isn't rocket science.

    If you want to spend some money, get a copy of Navicat, that will help you a lot with the MySQL.
     
  11. tICM macrumors newbie

    Joined:
    Jun 5, 2011
    #11
    Web sharing hasn't been an available option in (non-server) OS X for a couple of versions now.
     
  12. typonaut macrumors member

    Joined:
    May 7, 2014
    #12
    Hmm, well I suppose that's the tech industry's idea of an upgrade.

    Anyway, I did some checking, and it seems Apache is still installed on the latest system versions. In which case it's easy enough to start Apache up with the terminal.

    Open Terminal (note, you have to be an admin user to use "sudo").

    To start Apache: sudo apachectl start

    To stop Apache: sudo apachectl stop

    If you update the httpd.conf file(s) and you want to have Apache restart and reload the conf then you can use:

    sudo apachectl graceful

    There are probably lots of tutorial online about this, here's one, aimed specifically at Mavericks: http://brianflove.com/2013/10/23/os-x-mavericks-and-apache/
     
  13. ed45 thread starter macrumors newbie

    Joined:
    Mar 9, 2013
    #13
    GmbH Mamp vs Bitnami Mamp Stack


    Running Linux is definitely a consideration for the future. However, I've run into something unexpected. I was under the impression that the MAMP STACK app in the App Store and MAMP at mamp.info were offered by the same company, and now I've found out that they aren't. MAMP and MAMP PRO are made by GmbH, a German company, and MAMP STACK and a slew of other (free) stack apps for Wordpress, Drupal, Joomla, etc. are offered by Bitnami at the App Store.

    I'm leaning towards using Bitnami because it seems to be very active with an active support forum here and lots of good recent reviews at the appstore. MAMP support has been moved to Stackoverflow here and does not look very active. I realize that there are limitations inherent in App Store apps, but I'm only going to be using this to learn and "practice" PHP, and I'll probably go to a virtual environment for anything more serious.

    Has anyone tried both MAMP (or MAMP PRO) and MAMP STACK?
     
  14. ed45 thread starter macrumors newbie

    Joined:
    Mar 9, 2013
    #14
    Found an answer to my own question for anyone interested. Bitnami MAMP Stack reportedly has Mavericks related problems that have not yet been addressed. I'm going with MAMP.
     
  15. firedept, May 11, 2014
    Last edited: May 13, 2014

    firedept macrumors 603

    firedept

    Joined:
    Jul 8, 2011
    Location:
    Somewhere!
    #15
    I can tell you the forum at Stackoverflow will get you answers when required. I have had to use them and have had responses back within a few hours. Never longer than 24. I have also posted there with answers on occasion.

    Contacting the support at GmbH will also get you a direct email answer and very quickly.

    Update: Just upgrade to MAMP PRO 3 and all went smooth. Some of the updates included: CMS install made easy, can run Multi-PHP, Imagemagick activation, friendly interface, network access and some other good features.
     
  16. ed45 thread starter macrumors newbie

    Joined:
    Mar 9, 2013
    #16
    Hi firedept,

    Maybe you can help. I downloaded and installed MAMP and just for the heck of it the 2 week trial of MAMP Pro which ended up installing a suite of apps. When I tried to run MAMP I got a warning that I should only be running MAMP Pro. My post on Stack Overflow is here. Any advice?
     
  17. firedept macrumors 603

    firedept

    Joined:
    Jul 8, 2011
    Location:
    Somewhere!
    #17

    You should have two folders in your Applications Folder. One will be MAMP and the other MAMP PRO. Inside the MAMP PRO folder you will find the uninstaller for MAMP PRO. Just double click and your on your way. It will leave MAMP behind for you, which is the free version.
     

    Attached Files:

  18. Consultant macrumors G5

    Consultant

    Joined:
    Jun 27, 2007
    #18
    You can just go to http://codecademy.com and start learning.
     
  19. ed45 thread starter macrumors newbie

    Joined:
    Mar 9, 2013
    #19
    Thank you - worked like a charm. Much appreciated.
     
  20. boztek, May 17, 2014
    Last edited: May 17, 2014

    boztek macrumors newbie

    Joined:
    May 17, 2014
    #20
    Just use PHP

    By far the easiest way to learn PHP on a Mac is to use the built in web server.

    Create a directory and an index.php file, cd into that directory in the terminal and run the builtin server:

    Code:
    mkdir -pv ~/src/php
    echo "<?php phpinfo(); ?>" >> ~/src/php/index.php
    cd ~/src/php
    php -S localhost:9999>>/dev/null 2>/dev/null &
    open http://localhost:9999
    
    Use some other port number if you like.

    To quit just run 'fg' to bring the server back into term and CTRL-C to kill it.

    Voila.
     
  21. webdesignindia2 macrumors newbie

    Joined:
    May 12, 2014
    Location:
    India
    #21
    Mac supporting php that is good.but i am used windows operating system.
     
  22. JoelTheSuperior macrumors 6502

    JoelTheSuperior

    Joined:
    Feb 10, 2014
    Location:
    London, UK
    #22
    To be honest with you though I'd much rather develop on OS X than with Windows. Granted I don't work primarily in PHP anymore (although I have plenty of experience with it), it's wonderful to be able to run the same tools and programs on my Mac that I use on my servers and simply to have the much more powerful bash command line (powershell really just is not comparable).

    Right now I'm primarily working with Ruby on Rails and in all honesty I find that it simply 'behaves' more on OS X, especially once you start using gems that have *nix-specific dependencies. I found that developing on Windows with Rails was fairly frustrating as you would generally encounter fairly strange issues that Google unfortunately couldn't help with which I fortunately haven't had to experience yet on my Mac.

    Developing with PHP on Windows certainly isn't as much of an issue but once you get used to using some of the command line tools of *nix based OSes you'll wish you were using a Mac.
     
  23. firedept macrumors 603

    firedept

    Joined:
    Jul 8, 2011
    Location:
    Somewhere!
    #23
    The Windows version of MAMP is WAMP or XAMPP. WAMP is Windows only. XXAMP is cross-platform and a little more bloated than WAMP. Have a look at both and see what works best for you.
     
  24. theluggage macrumors 68030

    Joined:
    Jul 29, 2011
    #24
    Ick. The only reason I would develop for web on Windows was if I was targeting IIS, ASP, .Net, SQL Server etc. To be fair, one thing Microsoft has always done quite well is development tools, and people speak well of Visual Studio - provided you don't have any silly ideas about writing cross-platform stuff.

    Using Windows is one area where I definitely would resort to virtual Linux machines. For one thing... how does anybody assemble multi-target projects without a Unix-style filesystem, symbolic links and bash scripts?
     
  25. JoelTheSuperior macrumors 6502

    JoelTheSuperior

    Joined:
    Feb 10, 2014
    Location:
    London, UK
    #25
    Yeah I can understand that - I'm not a Windows developer but I can see why people enjoy Visual Studio. As far as web development goes I'm pretty focused on Linux but I do know some people who use ASP.net and swear by it.

    With that said, I do own a Windows desktop (primarily for the sake of gaming admittedly) and for the few times where I do need to work on my web development related projects I have a 'spare' PC running Ubuntu which I work remotely on.
     

Share This Page