Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

All my problems stemmed from trying to get mcrypt for PHP installed. Last night I gave in and followed a tutorial of how to do a totally fresh apache2 and php5.3.3 install. I did this using macports

Sadly, that didn't enable mcrypt for me last night, although I was pretty pleased that I got 5.3.3 running :)

The problem is that I have woken up this morning to find that my php version is back down to 5.3.1 which can only mean that OS X has reverted to my original Apache and PHP.

How to I tell OS X to use the software I installed via macports?

(And then I will ask a new question of how to enable mcrypt)

n.b. I can get the macports install to load by stopping the current web sharing in system prefs then this in terminal

 sudo /opt/local/apache2/bin/apachectl -k restart
share|improve this question
    
First you need to figure out what "use" means. –  Ignacio Vazquez-Abrams Aug 26 '10 at 10:31
    
currently I have apache in 2 places. /usr/sbin/apachectl and /opt/local/apache2/bin/apachectl . Mac os x is using the first one, I want it to use the second one. –  ed209 Aug 26 '10 at 10:39
    
Not a mac user but on a linux you I would have a look around in /etc/init.d. Somewhere there is probably a line that starts/calls /usr/sbin/apachectl. Comment that out and replace it with the call to apache2. –  Nifle Aug 26 '10 at 10:51
    
Macs don't have /etc/init.d –  Doug Harris Aug 26 '10 at 15:08

4 Answers 4

It's not so much your version of Apache/PHP have been reverted - it's just the wrong version is loaded.

If you have Mac OS X's Web Sharing enabled it will auto enable the version of Apache and PHP Apple provides using the LaunchDaemon org.apache.httpd.plist in /System/Library/LaunchDaemons (this will override MacPorts version). You'll want to disable this by either turning off Web Sharing in the Sharing Preference Pane or by running sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist.

When you installed Apache for MacPorts it installed a LaunchDaemon into /Library/LaunchDaemons which if enabled will start up the MacPorts version of Apache automatically. To enable it run sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist and you're off to the races.

If you're running apachectl to restart - make sure you've selected the right version. You may need to alter your $PATH to have /opt/local/apache2/bin before /usr/sbin

As for what version of PHP is being used; on the command line this will depend on your $PATH while for Apache it's entirely in your configuration of where the libphp5 module is. (/etc/apache2/ for the built in version, /opt/local/apache2/conf for the version MacPorts installed)

Apple.SE

share|improve this answer

As Ayaz suggested, you need to edit the plist. The proper path should be /System/Library/LaunchDaemons/org.apache.httpd.plist.

To make sure that you run the proper apachectl, modify the PATH environment variable in your shell startup script (e.g. ~/.bash_profile, ~/.zshrc or whatever) so that /opt/local/apache2/bin comes before /usr/sbin. In bash the syntax to prepend the macports apache dir is:

export PATH=/usr/local/apache2/bin:$PATH
share|improve this answer
    
macports removed this file (org.apache.httpd.plist) I believe –  ed209 Aug 28 '10 at 10:37

To fix your Apache problem, you can take a look at /Library/LaunchDaemons/org.apache.httpd.plist and edit it to taste.

share|improve this answer
    
I don't have that file! I do however have org.macports.apache2.plist –  ed209 Aug 26 '10 at 11:42
    
Apple's is stored at /System/Library/LaunchDaemons, /Library/LaunchDaemons has MacPorts' version. –  Chealion Aug 26 '10 at 23:29

Hmm... You're aware of the Personal Web Sharing you can activate in System Preferences -> Sharing. Are you trying to make that checkbox activate your custom build of Apache instead of the bundled one?

I don't know if this is possible, but I wouldn't recommend it. It's a better idea to just de-activate the basic build and use your custom one separately.

You've already got step 1, which is to turn off the default server in System Preferences. To cause the custom build to load at boot, investigate the /Library/LaunchDaemons/org.apache.httpd.plist file that you mentioned. See $man launchctl for more info about working with these files, and also this handy piece of software called Lingon.

With those tools (and maybe $ps -ax|grep httpd) you should be able to ensure that the running Apache build is the custom MacPorts install.

Ooh, that makes me think of something else: apachectl isn't the server, it's just a utility you use to control the server, which is httpd. Maybe the MacPorts apachectl is starting the bundled httpd? Or perhaps the MacPorts httpd is using the bundled PHP...

Personally, my approach to this would just be to alter the installed apache build by upgrading PHP as required, but hopefully you can use some of this to continue troubleshooting.

share|improve this answer
    
In the end I have just turned off the shipped apache/php and start the macports version when I need it. –  ed209 Aug 28 '10 at 10:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.