Safari hates .php?

Discussion in 'Mac Apps and Mac App Store' started by onlyONE, Aug 7, 2006.

  1. onlyONE macrumors member

    Joined:
    Jun 14, 2006
    #1
    I'm trying to create my first PHP website, with PHP includes and a few PHP databases. Only problem is I can't check my script and code, because Safari won't open my files, when I choose a program to open the file, Safari is displayed as an unavailable option. If it's easy to fix can someone please guide me in the right direction? If it's not and Safari is going to be fussy, what is the best alternative browser available for an Intel Mac? Thanks!
     
  2. ChrisBrightwell macrumors 68020

    ChrisBrightwell

    Joined:
    Apr 5, 2004
    Location:
    Huntsville, AL
    #2
    PHP is server-side scripting.

    That means that you need an HTTP server that will run the script and return the result to the browser.
     
  3. onlyONE thread starter macrumors member

    Joined:
    Jun 14, 2006
    #3
    Oh, yuck. So they won't just run on my hard drive? That's rather unfortunate. Thanks for the post though! :)
     
  4. ChrisBrightwell macrumors 68020

    ChrisBrightwell

    Joined:
    Apr 5, 2004
    Location:
    Huntsville, AL
    #4
    Well you may be able to run them locally ... I don't know much about OS X's built-in Apache server. PHP works pretty easily with Apache, though, so anything is possible.

    I'm sure someone else will chime in shortly with a link to a tutorial or how-to. :)
     
  5. blasto333 macrumors regular

    Joined:
    Jan 3, 2004
    #5
    As PHP is a server side language you will need to setup a web server on your computer so you can learn PHP.

    PHP is one of my favorite languages because it is fun and easy to use and powerful.

    To get a server up and running really fast, download MAMP:
    http://www.mamp.info/

    This will setup PHP, apache, mysql, and phpmyadmin.

    These tools are very helpful when developing php applications.

    I would also recommend using TextWrangler from barebones.com. This will help you program your code in php. It has nice features such as syntax highlighting and advanced searching.
     
  6. michaeldmartin macrumors regular

    michaeldmartin

    Joined:
    Jun 29, 2006
    Location:
    Testicles. That is all.
    #6
    Some web development apps will run the scripts. (Like dreamweaver)
     
  7. yg17 macrumors G5

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #7
    Yes, but dreamweaver is the root of all evil.


    Install MAMP. It's free, unlike DW, and will do exactly what you want.
     
  8. onlyONE thread starter macrumors member

    Joined:
    Jun 14, 2006
    #8
    Okay, I have downloaded MAMP onto my computer, I use Smultron as my HTML editor, and love it. If it turns out that TextWrangler is a superior choice I will certainly switch. How can I view the .php files? I am runnin the My SQL & Apache servers from MAMP, but can't figure out how to open my files...lol. :confused:
     
  9. ChrisBrightwell macrumors 68020

    ChrisBrightwell

    Joined:
    Apr 5, 2004
    Location:
    Huntsville, AL
    #9
    Did you RTFM? :p
     
  10. michaeldmartin macrumors regular

    michaeldmartin

    Joined:
    Jun 29, 2006
    Location:
    Testicles. That is all.
    #10
    By hosting it; turn the server on and put the files in the correct directory// I remember there being a shared folder for webpages or something; I don't remember what it was before i installed OS X server on the server..
     
  11. radiantm3 macrumors 65816

    radiantm3

    Joined:
    Oct 16, 2005
    Location:
    San Jose, CA
    #11
    PHP is already built into OS X. All it needs is to be enabled. Personally, I use headdress: http://headdress.twinsparc.com/ for managing my development environment.
     
  12. onlyONE thread starter macrumors member

    Joined:
    Jun 14, 2006
    #12
    Okay, I have turned on the built in PHP server in OS X, enabled Person Web Sharing and went into my website through System Preferences. I have a website named with a .html extension and that one works fine when I open to view it, however if I try to open .shtml files or .php files they all just show up in Safari as code. :confused: Ug. Thanks so much for bearing with me guys, you're tons of help! :)
     
  13. radiantm3 macrumors 65816

    radiantm3

    Joined:
    Oct 16, 2005
    Location:
    San Jose, CA
    #13
    How are you trying to open them? By directly running the file in the finder? You need to access them via http. So if your index.php file is in your ~/sites/ folder, you need to access it by typing http://localhost/~yourusernamehere/index.php in your browser.
     

Share This Page