Which version of Apache am I running?

Ryan Schmidt ryandesign at macports.org
Wed Aug 1 12:49:00 PDT 2007


On Aug 1, 2007, at 06:58, Elise van Looij wrote:

> Op 31-jul-2007, om 22:17 heeft Jyrki Wahlstedt het volgende  
> geschreven:
>
>>> I don't know why but apache 2 has its own directory. So you have  
>>> to add
>>> the following to your $PATH:
>>>
>>> /opt/local/apache2/bin
>>
>> And this must be put before /usr/sbin in the PATH, as otherwise  
>> the result remains the same …
>>
>>> To find out which version of an application is used you can use the
>>> following command. This prints the path to the application.
>>>
>>> which apachectl
>>
>> This command uses PATH, because of which the order is important!
>
> Yes, that must be the problem, but how do I fix it? I made a new  
> order like so:
>
> /opt/local/bin:
> /opt/local/sbin:
> /opt/local/apache2/bin:
> /opt/local/bin/mysql5:
> /opt/local/lib/mysql5/bin:
> /opt/local/lib/mysql5/bin/mysql:
> /opt/local/lib/mysql5/bin/mysqladmin:
> /bin:
> /sbin:
> /usr/bin:
> /usr/local/bin:
> /usr/local/mysql/bin:
> /usr/sbin

Note that there's no use in listing /opt/local/lib/mysql5/bin/mysql  
and /opt/local/lib/mysql5/bin/mysqladmin in your PATH. PATH can only  
hold directories, and those are files. You can safely remove those  
two items, since the directory they're in is already in your PATH.

> and entered that in the terminal:
>
> export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/apache2/bin:/ 
> opt/local/bin/mysql5:/opt/local/lib/mysql5/bin:/opt/local/lib/ 
> mysql5/bin/mysql:/opt/local/lib/mysql5/bin/mysqladmin:/bin:/sbin:/ 
> usr/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/sbin

Ok, so you have thus set the PATH for that instance of the Terminal.  
But that goes away as soon as you close that Terminal window.

> But even after a restart, the path is still in the wrong order:
>
> echo $PATH
> /opt/local/lib/mysql5/bin/mysql:/opt/local/bin/mysql5:/usr/local/ 
> mysql/bin:/opt/local/bin:/opt/local/sbin:/opt/local/lib/mysql5/bin:/ 
> usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/opt/local/bin:/opt/ 
> local/lib/mysql5/bin/mysqladmin:/opt/local/lib/mysql5/bin/mysql
>
> /opt/local/lib/mysql5/bin/mysql;
> /opt/local/bin/mysql5;
> /usr/local/mysql/bin;
> /opt/local/bin;
> /opt/local/sbin;
> /opt/local/lib/mysql5/bin;
> /usr/local/bin;
> /bin;
> /sbin;
> /usr/bin;
> /usr/sbin;
> /opt/local/bin;
> /opt/local/lib/mysql5/bin/mysqladmin;
> /opt/local/lib/mysql5/bin/mysql

If you want the PATH to be persistent, you have to put the "export"  
line in a file that the Terminal reads when it starts.

> I don't quite understand how this comes about: I'm not even sure  
> where many of these values come from. Based on what I've googled, I  
> gather that these variables are specified in the system and user  
> profile files. But if I ask 'pico /etc/profile', I get:
> -----------------------------------------------------------
> PATH="/opt/local/bin:/opt/local/sbin:/opt/local/lib/mysql5/bin:/usr/ 
> local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
> export PATH
>
> if [ "${BASH-no}" != "no" ]; then
>         [ -r /etc/bashrc ] && . /etc/bashrc
> fi
> -----------------------------------------------------------
>
>
> Similarly, 'pico ~/.profile' produces:
> -----------------------------------------------------------
> #
> # Your previous .profile  (if any) is saved as .profile.dpsaved
> # Setting the path for DarwinPorts.
> export PATH=/opt/local/bin:/opt/local/sbin:$PATH
> -----------------------------------------------------------
>
>
> So that should ensure that the /opt/local/bin path always comes  
> first, right? Your help is greatly appreciated: UNIX for Dummies  
> (3rd edition) is not much help here.

It sounds like at some point you modified /etc/profile, and  
~/.profile, to contain those /opt/local directories (since they would  
not have been there by default) but that there's another file that  
the terminal is using instead of those. Possibilities include /etc/ 
bashrc, ~/.bash_profile and ~/.bashrc. That's assuming your shell is  
bash. Is it? Find out with "echo $SHELL".





More information about the macports-users mailing list