Mac osx, the apache webserver and PHP

Discussion in 'Web Design and Development' started by Quboid, Jul 10, 2007.

  1. Quboid macrumors 6502

    Joined:
    Oct 16, 2006
    Location:
    everywhere
    #1
    Hello all

    Sorry if this is an extremely trivila question, but i was wondering does the apache server included in mac's OSX support PHP. I am very new to PHP as a matter of fact i am just getting started with it. So I was wondering If i can use that apache webserver to test me code. If not, how do I get it to work?

    Also, does anybody have any advice on learning PHP?
    I am a computer engineering student and we according to my course outline the languages i would be learning are C (which i alreaady mastered) C++, and java, i've also been learning cocoa on my own. So i have a few questions.

    1. Is PHP even worth it?
    2. If it is where should i start?
    2.1 what is it good for?
    3. If it is not worth it what should i look into instead?

    Ps. I'm on summer holidays and i'm bored.
     
  2. ppc_michael Guest

    ppc_michael

    Joined:
    Apr 26, 2005
    Location:
    Los Angeles, CA
    #2
    Yes, PHP runs wonderfully on Mac OS X / Apache.

    Apple has official installation documentation here:
    http://developer.apple.com/internet/opensource/php.html

    Or if you don't like the command line, entropy.ch has an installer:
    http://www.entropy.ch/software/macosx/

    PHP is excellent, and you'll be very familiar with a lot of it already since you know C. I think it's definitely worth knowing, because it can dynamically build web pages for you, handle forms, and interface with MySQL. It's all server-side, so you don't have to worry about browser compatibility or platforms.

    EDIT: And I just noticed that my MacBook Pro came with PHP installed already. So check before you install, I guess. :)
     
  3. Quboid thread starter macrumors 6502

    Joined:
    Oct 16, 2006
    Location:
    everywhere
    #3

    Sorry for taking so long to see this reply, i've been out since i made this thread. you say your macbook pro has PHP installed, how do i check for it on my Macbook?
     
  4. OutThere macrumors 603

    OutThere

    Joined:
    Dec 19, 2002
    Location:
    NYC
    #4
    Make a text file (foo.php or whatever) with:

    PHP:
    <?
    phpinfo();
    ?>
    in it, drop it in your webserver folder and try to open it in your browser. If it comes up as text, you don't have php installed. Otherwise you'll see a whole bunch of info about the version you have installed.

    I find php infinitely useful for creating interactive, content based web sites...if you don't plan on doing that there's not much in it for you.
     
  5. nightelf macrumors 6502

    Joined:
    Mar 25, 2003
  6. ppc_michael Guest

    ppc_michael

    Joined:
    Apr 26, 2005
    Location:
    Los Angeles, CA
    #6
    Easiest way is probably from the command line. Create a PHP file, then in Terminal type php pathtothefile.php and it will show the output in Terminal.
     
  7. Quboid thread starter macrumors 6502

    Joined:
    Oct 16, 2006
    Location:
    everywhere
    #7
    Ok, i followed the steps to uncomment and enable php and it didn't work. So i downloaded a php bundle and installed it. But now, it seems like my apache server is broken (I have no idea how). When i try to restart it, it just doesn't i tried in the terminal and i get a wierd message.

    zsika-phillips-computer:~ zsikaphillip$ sudo /System/Library/StartupItems/Apache/Apache restart
    Password:
    Restarting Apache web server
    /usr/sbin/apachectl restart: httpd not running, trying to start
    Processing config directory: /private/etc/httpd/users/*.conf
    Processing config file: /private/etc/httpd/users/+entropy-php.conf
    Syntax error on line 8 of /private/etc/httpd/users/+entropy-php.conf:
    Cannot load /usr/local/php5/libphp5.so into server: (reason unknown)
    /usr/sbin/apachectl restart: httpd could not be started

    Anybody have any adea what is going on? cuase i really use that server alot, and i would like to restore it.
     
  8. Quboid thread starter macrumors 6502

    Joined:
    Oct 16, 2006
    Location:
    everywhere
    #8
    I really need some help with this one, can anybody help me out here?
     
  9. frankblundt macrumors 65816

    frankblundt

    Joined:
    Sep 19, 2005
    Location:
    South of the border
    #9
    I like the Entropy packages, but had similar issues trying to get PHP to work with Apache, and in the end installed his Apache bundle too.

    If all you want is something to play with, using MAMP would be far easier (and you'll get MySQL too). Just make sure you use the altenative port settings so it doesn't conflict with the built-in Apache, or turn off the built-in one by turning off Personal Web Sharing in Sys Prefs > Sharing

    To get your apache back, just delete the /private/etc/httpd/users/+entropy-php.conf file (you'll need to use Finder > Go menu > Go to folder to get there unless you have hidden files viewable)
     
  10. Quboid thread starter macrumors 6502

    Joined:
    Oct 16, 2006
    Location:
    everywhere
    #10
    For tonight all i want is my server back up. how do i make hidden files viewable, cause the "go to folder" isn't working.
     
  11. Quboid thread starter macrumors 6502

    Joined:
    Oct 16, 2006
    Location:
    everywhere
    #11
    Well, i guess i don't need an answer for this anymore since i went to darwin and removed that file as the root user. Thanks for all the help!
     
  12. frankblundt macrumors 65816

    frankblundt

    Joined:
    Sep 19, 2005
    Location:
    South of the border
    #12
    Go to folder will only work with a folder address...

    you might want to look at something like Xupport or a similar system cleaning/modifying utility, which allows you to turn off the Finder's file hiding, which can be handy when you're doing this kind of back-end stuff (especially as packages like the Entropy ones tend to install into hidden folders like /usr/local )
     
  13. Quboid thread starter macrumors 6502

    Joined:
    Oct 16, 2006
    Location:
    everywhere
    #13
    Ok, i'll looking into that.... But i actually turned off file hiding from the terminal too. I just couldn't find that config file. Even with file sharing turned off.

    I really want to get php up and running still, but i don't want to mess with my server no more. Any advice?
     
  14. frankblundt macrumors 65816

    frankblundt

    Joined:
    Sep 19, 2005
    Location:
    South of the border
    #14
    MAMP, it really is the easiest way to try stuff out. the default settings use different port addresses for Apache and MySQL so you can run it without affecting your own Apache server - it just means you have to address stuff by port (eg http://localhost:8888/somefolder/index.php).

    Did you get Apache back up? Or is it still giving errors? the same ones? I thought you deleted the entropy conf file already?
     

Share This Page