Installing PHP on Mavericks

Discussion in 'Web Design and Development' started by jason.siegel, Feb 3, 2014.

  1. jason.siegel macrumors 6502

    Joined:
    Jun 15, 2011
    #1
  2. godrifle macrumors regular

    godrifle

    Joined:
    Oct 20, 2003
    Location:
    Fort Thomas, KY
    #2
    PHP is built in to Mavericks. You can test via the Terminal by typing in: php -v
     
  3. jason.siegel thread starter macrumors 6502

    Joined:
    Jun 15, 2011
    #3
    Okay, but I can't run it. I can't even open a PHP file with Safari.
     
  4. godrifle macrumors regular

    godrifle

    Joined:
    Oct 20, 2003
    Location:
    Fort Thomas, KY
    #4
    At a minimum, all you need to do is following the instructions under Apache in the URL you shared, in order to enable Apache (the web server) and (in step 3 under the Apache instructions) to enable Apache to use PHP.
     
  5. jason.siegel thread starter macrumors 6502

    Joined:
    Jun 15, 2011
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    The first command should be:
    Code:
    [SIZE="5"]cd /etc/apache2[/SIZE]
    
    you have:
    Code:
    [SIZE="5"]ed /etc/apache2[/SIZE]
    
    Zoom in to the article so you can see the exact commands. Accuracy is important.
     
  7. firedept macrumors 603

    firedept

    Joined:
    Jul 8, 2011
    Location:
    Somewhere!
    #7
    If you are struggling, you could simply install MAMP and be done with it. I know PHP it comes with macs, but MAMP makes it so much easier to run PHP. It is free, easy to get up running, and then you have something easy for future use.
     
  8. Apple Key macrumors 6502a

    Apple Key

    Joined:
    Jan 4, 2012
    #8
    In Terminal: sudo apachectl start

    Place the file in this location: /Library/WebServer/Documents/

    Open this url in your browser: http://localhost
     
  9. BornAgainMac macrumors 603

    BornAgainMac

    Joined:
    Feb 4, 2004
    Location:
    Florida Resident
    #9
    Also the MAMP Stack is available from the Mac App Store and is also still free.
     
  10. fcomstoc macrumors member

    fcomstoc

    Joined:
    Sep 12, 2013
    Location:
    Las Vegas, NV
    #10
    +1 for MAMP, I am a web developer and it is great for quick php testing, I would also suggest setting up symbolic links to your website file(s) in the MAMP htdocs folder so that you dont have to work out of that folder - you can work out of any folder (documents, etc.) it is much easier than setting up an entire php/apache test server on your mac
     
  11. jason.siegel thread starter macrumors 6502

    Joined:
    Jun 15, 2011
    #11
    I installed and ran MAMP, but I can't select PHP extension files to open in Safari.
     
  12. firedept macrumors 603

    firedept

    Joined:
    Jul 8, 2011
    Location:
    Somewhere!
    #12
    Check these things out and see if something is wrong or if you are getting errors. You were pretty vague in your response.

    There could possibly be a setting on your ports that is wrong. The other thing is to make sure MAMP is turned on and connected. One other thing to check is that you paths are correct and your files are in the proper place.

    I am not an expert with this, but know these sre some of things that can cause problems.
     
  13. jason.siegel thread starter macrumors 6502

    Joined:
    Jun 15, 2011
    #13
    I'm not receiving errors. What I mean is that there's no way to open (I don't mean parse) the file itself. File > Open file does not allow me to select a file with a PHP extension, for example.
     
  14. fcomstoc macrumors member

    fcomstoc

    Joined:
    Sep 12, 2013
    Location:
    Las Vegas, NV
    #14
    You are trying to open these files in a web browser right, you dont actually open anything in MAMP.
     
  15. jason.siegel thread starter macrumors 6502

    Joined:
    Jun 15, 2011
    #15
    Yes. Notice that the PHP file is grayed out.
     

    Attached Files:

  16. fcomstoc macrumors member

    fcomstoc

    Joined:
    Sep 12, 2013
    Location:
    Las Vegas, NV
    #16

    You cannot open it that way, MAMP creates a fake server on your computer but the files you are trying to open are not in the servers directory open a terminal window and type:

    ln -s /Users/jasonsiegel/Dropbox/ /Applications/MAMP/htdocs/rand

    This creates a symbolic link from your dropbox to the server's directory.

    Make sure mamp is running and navigate your browser to http://localhost:8888/
     
  17. jason.siegel thread starter macrumors 6502

    Joined:
    Jun 15, 2011
  18. fcomstoc macrumors member

    fcomstoc

    Joined:
    Sep 12, 2013
    Location:
    Las Vegas, NV
    #18
    Not a problem, you can use the same setup for any other sites/php files that you want to test.
     
  19. jason.siegel thread starter macrumors 6502

    Joined:
    Jun 15, 2011
    #19
    Sometimes my script doesn't appear to run. It usually uses a header redirect send me to a particular homepage, but sometimes it just gets stuck. If it's not my script, why is it freezing?
     

    Attached Files:

  20. DelisleBA.info macrumors member

    Joined:
    Apr 12, 2011
    Location:
    Athens, OH
    #20
    Hope it helps.

    Here is a link to a youtube video I made for Setup of Apache, PHP, MySQL and WordPress on OS X Mountain Lion. I have not had a chance to test it on 10.9 yet but would think the PHP part would be the same. I hope it helps.

    The PHP part starts at 3:24.

    http://www.youtube.com/watch?v=3fBR7D_5wGo&feature=share
     
  21. fcomstoc macrumors member

    fcomstoc

    Joined:
    Sep 12, 2013
    Location:
    Las Vegas, NV
    #21
    Are you sure it is not an issue with your browser, did you try another one? I would make sure that you dont have any browser addons or anything installed. If you post the script I/we could take a look at it.
     
  22. AdrianK macrumors 68020

    Joined:
    Feb 19, 2011
    #22
    You can check the headers you page is sending in Safari by right clicking > Inspect Element and going to the network tab (I don't have a mac nearby, so the options may be named slightly differently), or using a tool like curl.

    If your PHP page isn't displaying errors (although I'd expect it to since MAMP is for development), you may need to force PHP to display errors (error_reporting(E_ALL)) or look at your apache logs.
     

Share This Page