1 2 3 4 Previous Next 49 Replies Latest reply: Mar 28, 2012 6:58 AM by BillBaroud Go to original post
  • 30. Re: Local Web Server for Lion
    eaglex690 Level 1 Level 1 (0 points)

    Ok thanks I'll try to put things back the way they were before. I'll try to take notes the next time I'll do something like this, it may help. Anyway thanks for the support

  • 31. Re: Local Web Server for Lion
    Jiri Krecek Level 4 Level 4 (1,080 points)

    @ etresoft

     

    Thanks for this article. Trying to set up vhosts myself.

     

    As to your comment on why the web sharing will not start up in Lion, someone here found out why it got broken and how to fix it. I've simplified the instructions:

     

    After upgrading to Lion, some users lost the ability to turn on the web sharing service in OS X. This was partially caused by the Apache httpd.conf file referencing to a non-existing file. PHP was upgraded to 5.3 in Lion, but the old httpd.conf keeps referencing 5 lib file. You could verify this by following these instructions below:

    1. 1.Go to System Preferences and try to start Web Sharing
    2. 2.It will turn yellow for a split of a second and then back to grey
    3. 3.Start Console and look at the system log
    4. 4.You could see something like this:
      dyld: Library not loaded: /usr/lib/libpq.5.dylib
      Referenced from: /usr/sbin/httpd
      Reason: image not found
      Job appears to have crashed: Trace/BPT trap: 5
      Throttling respawn: Will start in 10 seconds
    5. 5.Apache is referencing a file libpq.5.dylib, but that file doesn’t exist!
    6. 6.However a file libpq.5.3.dylib exists at that location instead
    7. 7.All you have to do to make the missing file link to the new version 5.3 file
    8. 8.Type this in Terminal: sudo ln -s /usr/lib/libpq.5.3.dylib /usr/lib/libpq.5.dylib
    9. 9.Restart Web Sharing in System Preferences
    10. 10.You should be good to go!

    I'm taking no credit for this fix. I just dug it out buried deep in this discussion forum.

  • 32. Re: Local Web Server for Lion
    etresoft Level 7 Level 7 (24,270 points)

    But it would start up, if you kept trying it. My wife's iMac has a standard 10.7.3 installation (not like my machine). It has all of the appropriate libraries and links. Perhaps it was just dot zero flakiness.

  • 33. Re: Local Web Server for Lion
    john cummin1 Level 2 Level 2 (400 points)

    can anyone tell me what i'm actually supposed to do to carry out this part of the instrucitons please?:

     

    Edit the launchd config file for Apache:

    sudo vi /System/Library/LaunchDaemons/org.apache.httpd.plist

     

    i ignored it and carried on and typed

    sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

    but that gave

    launchctl: Error unloading: org.apache.httpd

    so i guess it'd down to me not editing the launchd file for Apache, whatever that means

     

    thanks.

  • 34. Re: Local Web Server for Lion
    etresoft Level 7 Level 7 (24,270 points)

    I think that was part of my trying to get around a bug in Lion websharing. Sometimes it doesn't want to start when you click on the Web Sharing box in System Preferences. Just keep clicking until it starts.

     

    You can ignore that line and

    sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

    sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

     

    I never did figure out what was wrong. I just checked a vanilla 10.7.3 machine and the bug is still there. Plus, when I wrote this, the User Tips weren't enabled yet. They are now, so I need to re-do this as a real user tip. No time like the present, eh?

  • 35. Re: Local Web Server for Lion
    BillBaroud Level 1 Level 1 (0 points)

    Dear All,

     

    I'm quite a beginner in apache / PHP settings and developpment, but still, here is my problem.

    I want to settup a apache / PHP / postgresql framework.

     

    First I've installed postgresql (9.1) in /Library/PostgreSQL/9.1/bin/ and check I can create and use DB : OK

     

    I've set up my /etc/apache2/http.conf to activate PHP (uncommenting corresponding line)

    I've set up my /etc/php.ini (/usr/libexec/libphp5.so)

     

    Unfortunately, with this configuation,I wasn't able to use postgresql.

     

    The best way to sove my problem was to recompile PHP using the -with-pgsql option, in order to make PHP deals with postgres.

    So I've compiled PHP 5.4.0 using the following configuration :

    ./configure --with-pgsql=/Library/PostgreSQL/9.1/bin/ --prefix=/usr --with-apxs2=/usr/bin/apxs

    I've then check I can access to my postgres DB with a simple PHP code : OK

     

    Then launching apache via web sharing (from syst. pref.) and opening a brief PHP file (one line : <?PHP phpinfo() ?>).

    The web page indicate that PHP 5.3.8 was launched, not PHP5.4.0. (also in /var/log/apache2/error_log)

     

    I though I could  solve my probleme by updating the apache2 to 2.4.1

    So I updated apache 2.2.1 (build in release of Lion) to 2.4.1, so as it could integrate the newly installed PHP 5.4.0 (and not the PHP 5.3.8).

    I used the following configuration :

    ./configure --prefix=/usr --enable-modules=all --enable-mods-shared=all

     

    But this was useless, since the apache launched by syst.pref web sharing click boxe is still apache 2.2.1 (set in /usr/sbin) but not apache 2.4.1 :

     

    solath:bin meurice$ /usr/sbin/httpd -v

     

    Server version: Apache/2.2.21 (Unix)

    Server built:   Nov 15 2011 15:12:57

     

    solath:bin meurice$ /usr/bin/httpd -v

     

    Server version: Apache/2.4.1 (Unix)

    Server built:   Mar 27 2012 20:54:26

     

     

    I probably missing a configuration step, but I can't figure it out.

    I've tried to modify the file /System/Library/LaunchDaemons/org.apache.httpd.plist, replacing "/usr/sbin" by /usr/bin", but it make the activation of apache via syst.pref. web sharing click box failed.

     

    I've tried to copy the libphp5.so comming with PHP 5.4.0 to /usr/libexec/apache2/

    but then I also failed to launch apache2

     

    I would be very grateful if you could give me some clues to succed, because yet, I didn't find anything in google.

     

    I would rather not use any MAMP or mac port installation, because I would prefer to clearly understand what I'm doing. The benefit will be greater for my knowledges, and moreover I'm pretty sure it will be very helpful since I want to step into PHP developpement, and understanding the way apache / PHP are connected could be helpful in debugging.

     

     

    Bests.

  • 36. Re: Local Web Server for Lion
    etresoft Level 7 Level 7 (24,270 points)

    BillBaroud wrote:

     

    I want to settup a apache / PHP / postgresql framework.

     

    Why PostgreSQL? MySQL is so easy to install and will do everything short of decent spatial extensions. If you really need PostgreSQL, OK, but there are far fewer people to help. I've never installed it, so all I can do is work around that fact.

     

    Unfortunately, with this configuation,I wasn't able to use postgresql.

     

    Why not? What errors did you get?

     

    The best way to sove my problem was to recompile PHP using the -with-pgsql option, in order to make PHP deals with postgres.

     

    Are you sure about that? The stock PHP seems to include both PDO and standard PostgreSQL drivers. You've just tripled (at least) the complexity of your problem.

     

    So I've compiled PHP 5.4.0 using the following configuration :

    ./configure --with-pgsql=/Library/PostgreSQL/9.1/bin/ --prefix=/usr --with-apxs2=/usr/bin/apxs

    I've then check I can access to my postgres DB with a simple PHP code : OK

     

    Then launching apache via web sharing (from syst. pref.) and opening a brief PHP file (one line : <?PHP phpinfo() ?>).

    The web page indicate that PHP 5.3.8 was launched, not PHP5.4.0. (also in /var/log/apache2/error_log)

     

    Well, if you really, really want to run PostreSQL, and you really, really, really want to run a newer version of PHP, there are ways to accomplish that. Of course very few people do such things.

     

    I though I could  solve my probleme by updating the apache2 to 2.4.1

    So I updated apache 2.2.1 (build in release of Lion) to 2.4.1, so as it could integrate the newly installed PHP 5.4.0 (and not the PHP 5.3.8).

    I used the following configuration :

    ./configure --prefix=/usr --enable-modules=all --enable-mods-shared=all

     

    OK. Whoa. Time out. Full stop.

     

    But this was useless, since the apache launched by syst.pref web sharing click boxe is still apache 2.2.1 (set in /usr/sbin) but not apache 2.4.1 :

     

    solath:bin meurice$ /usr/sbin/httpd -v

     

    Server version: Apache/2.2.21 (Unix)

    Server built:   Nov 15 2011 15:12:57

     

    solath:bin meurice$ /usr/bin/httpd -v

     

    Server version: Apache/2.4.1 (Unix)

    Server built:   Mar 27 2012 20:54:26

     

     

    I probably missing a configuration step, but I can't figure it out.

    I've tried to modify the file /System/Library/LaunchDaemons/org.apache.httpd.plist, replacing "/usr/sbin" by /usr/bin", but it make the activation of apache via syst.pref. web sharing click box failed.

     

    No más ! No más !

     

    I've tried to copy the libphp5.so comming with PHP 5.4.0 to /usr/libexec/apache2/

    but then I also failed to launch apache2

     

    And now, we reinstall the operating system

     

    I would be very grateful if you could give me some clues to succed, because yet, I didn't find anything in google.

     

    I would rather not use any MAMP or mac port installation, because I would prefer to clearly understand what I'm doing.

     

    After reinstalling the OS, get back to step where you couldn't connect to your PostgreSQL database with PHP. When something doesn't work, please ask first. Don't go corrupting your OS.

  • 37. Re: Local Web Server for Lion
    etresoft Level 7 Level 7 (24,270 points)

    User Tips are now available!

     

    This thread is now obsolete.

     

    Please see the User Tips:

    Setting up a local web server on Lion

    and

    Installing MySQL on Lion

  • 38. Re: Local Web Server for Lion
    BillBaroud Level 1 Level 1 (0 points)

    First many thanks for considering my question, and for your answer.

     

    BillBaroud wrote:

     

    I want to settup a apache / PHP / postgresql framework.

     

     

     

    Why PostgreSQL? MySQL is so easy to install and will do everything short of decent spatial extensions. If you really need PostgreSQL, OK, but there are far fewer people to help. I've never installed it, so all I can do is work around that fact.

     

     

    OK, I really need postgreSQL.

     

     

    Unfortunately, with this configuation,I wasn't able to use postgresql.

     

    Why not? What errors did you get?

     

     

    I Got this error :

     

    PHP Fatal error:  Call to undefined function pg_connect()

     

    the pg_connect() is the PHP function to make a connection to the SGDB, like mysql_connect but for PostgreSQL.

     

     

     

     

    Well, if you really, really want to run PostreSQL, and you really, really, really want to run a newer version of PHP, there are ways to accomplish that. Of course very few people do such things.

     

    Did the ways I follow were bad ? Could you please give me the good way to upgrade apache for macosx then ?

     

     

    After reinstalling the OS, get back to step where you couldn't connect to your PostgreSQL database with PHP. When something doesn't work, please ask first. Don't go corrupting your OS.

     

    OK no worry about that. My system work just fine, I didn't make anything undoable. All I want is to upgrade apache so it integrate the newer release of PHP (5.4.0), not the oldest one (5.3.8). I thought it was easy to upgrade tools with mac osx but for this particular apache upgrade it's not obvious.

     

    again thank for your answers

  • 39. Re: Local Web Server for Lion
    etresoft Level 7 Level 7 (24,270 points)

    BillBaroud wrote:

     

    I Got this error :

     

    PHP Fatal error:  Call to undefined function pg_connect()

     

    It sure looked like PHP had PostgreSQL support incuded. Do you have/need PostgreSQL client libraries? They might be a separate install. That is the problem with PostgreSQL, more people are starting from scratch there.

     

    I will investigate.

     

    Did the ways I follow were bad ? Could you please give me the good way to upgrade apache for macosx then ?

     

    Replacing PHP and/or Apache is definitely outside the scope of this thread. It is about setting up the software that comes included with MacOS X. There are ways to upgrade included software, but very few, if any, people really need to do that. Plus, it is a hassle so the people who know how to do those things typically don't want to bother.

     

    However, with Lion, you can now easily run inside a VM. That is what I did when I updated my new User Tips yesterday. I could try using the VM to upgrade Apache and PHP if that were really the best solution. If you really do need to do that, it would be best to start a new question dedicated to that task. Of course, you will get a round of questions asking why you would want to do such a thing - as you should.

     

    OK no worry about that. My system work just fine, I didn't make anything undoable. All I want is to upgrade apache so it integrate the newer release of PHP (5.4.0), not the oldest one (5.3.8).

     

    Is that what you want to do? Or do you want to use PostgreSQL?

     

    I thought it was easy to upgrade tools with mac osx but for this particular apache upgrade it's not obvious.

     

    It is not trivial. MacOS X isn't designed for that. It can be done by people who know how, but such people typically don't see the need.

  • 40. Re: Local Web Server for Lion
    BillBaroud Level 1 Level 1 (0 points)

    OK no worry about that. My system work just fine, I didn't make anything undoable. All I want is to upgrade apache so it integrate the newer release of PHP (5.4.0), not the oldest one (5.3.8).

     

    Is that what you want to do? Or do you want to use PostgreSQL?

     

     

     

    Since I was thinking that the 5.3.8 PHP build of mac osx seems not to handle Postgresql, I choose to compile it so as it deals with Postgresql.

    For now, my installation seems to work (PHP and postgresql). Ican write PHP that remotelly call postgresql (http://fr.php.net/manual/en/book.pgsql.php).

     

    The problem I had now is to tell apache to use the correct PHP (mean the 5.4.0, not the 5.3.8). I didn't find a way to do this in conf files of apache.

    One solution I saw was to re-install apache : I've re-install it using the -enable-layout = Darwin option.

    Yet, apache is working, but still not able to deal with PHP.... pfiouuu

     

    Anyway, thanks again for the attention you give to this topic.

  • 41. Re: Local Web Server for Lion
    etresoft Level 7 Level 7 (24,270 points)

     

    BillBaroud wrote:

     

    Since I was thinking that the 5.3.8 PHP build of mac osx seems not to handle Postgresql, I choose to compile it so as it deals with Postgresql.

    I just installed PostreSQL and it worked right out of the box.

     

    For now, my installation seems to work (PHP and postgresql). Ican write PHP that remotelly call postgresql (http://fr.php.net/manual/en/book.pgsql.php).

    OK. I'm confused again. Does it work or doesn't it? Or do you mean your installation and not the default?

     

    Maybe go back to step one and see about getting the default software working. It works for me.

  • 42. Re: Local Web Server for Lion
    BillBaroud Level 1 Level 1 (0 points)

    Ok to summarize what is know working :

    - Postgresql is working by itself

    - I can know access to my postgresql DB with PHP (since I've updated PHP to 5.4.0)

    - I have installed apache 2.4.1:

         - I can launch it via syst.prefs > share > web sharing (cool)

          - Seeing /var/log/apache2/error_log, I can see that It uses PHP 5.4.0 (also cool) :

        

    [Wed Mar 28 14:04:20.650630 2012] [mpm_event:notice] [pid 937:tid 140735167261024] AH00489: Apache/2.4.1 (Unix) PHP/5.4.0 configured -- resuming normal operations

    [Wed Mar 28 14:04:20.650701 2012] [core:notice] [pid 937:tid 140735167261024] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND -D WEBSHARING_ON'

     

         - But when opening a PHP script with a web browser, the code is displayed not interpreted .... which make me think something is wrong in http.conf ....

  • 43. Re: Local Web Server for Lion
    etresoft Level 7 Level 7 (24,270 points)

    BillBaroud wrote:

     

    Ok to summarize what is know working :

    - Postgresql is working by itself

    - I can know access to my postgresql DB with PHP (since I've updated PHP to 5.4.0)

     

    Yes, but I can access my PostgreSQL database with the built-in PHP. I haven't installed any other PHP or Apache. Everything works fine.

     

    You cannot say the same thing. I suggest you go back to square one. Undo any system changes. Verify that a simple info.php works with the built-in Apache and PHP. Then try PostgreSQL. This was why I was so worried about all the changes you have made. Now you cannot perform simple tasks. You have made extensive changes to the system, none of which were required.

     

    It may still be an interesting exercise to upgrade Apache and PHP on MacOS X and do it correctly. It is not something that you need to undertake at this time. First get the built-in software running correctly. Then, if you have a compelling need to upgrade something, start a new question for that. You will have to be able to definitively prove that you need to upgrade Apache and PHP and are able to get that working, otherwise, nobody will care. You haven't proved that so far.

     

  • 44. Re: Local Web Server for Lion
    BillBaroud Level 1 Level 1 (0 points)

    Merf OK.

     

    So I'm now re-installing OSX Lion .

     

    Then I'll get PostgreSQL (9.1)

     

    Where did you installed it ?

    How did you check you can access PostgresSQL using PHP (So I can perform the same test as yours) ?

    Does the simple info.php correspond to <?PHP phpinfo(); ?>

     

    And I agree with you, I'll post a new message before doing any installation process.

     

    bests,