问题描述:

I recently tried to install monit on Ubuntu Natty from source. Here's my code:

apt-get -y install openssl libssl-dev bison flex

mkdir src && cd src

wget http://mmonit.com/monit/dist/monit-5.3.2.tar.gz

tar xzf monit-5.3.2.tar.gz

cd monit-5.3.2

./configure --prefix=/usr/local/monit

make && make install

However, when I install Monit using apt-get I am able to call monit directly from the command line using the keyword monit. I am not able to do so when I do the install from source. The same goes for PHP.

How can I enable this feature for when I install Monit (and other Linux programs) from source?

Thanks in advance.

EDIT

I was able to solve this by doing the following:

printf "\nPATH=/usr/local/monit/bin:\${PATH}\n" >> ~/.profile

source ~/.profile

This will apply for the currently logged in user (in my case root). To make it system-wide simply replace ~/.profile with /etc/profile.

So now I can can call monit (and any other program I install from source).

网友答案:

Edit your /etc/profile to add the path /usr/local/monit to the PATH variable.

For ex, if you earlier had this.

PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"

You could change it to

PATH="/usr/local/monit:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"

网友答案:

Using that command to install it will put it in /usr/local/monit, which won't be in your $PATH, as others have said. There are several options besides modifying your path, though. For instance, you can create a symbolic link from the real executable to one in your path. So if the executable is /usr/local/monit/monit, you can

ln -s /usr/local/monit/monit /usr/local/bin/monit

The advantage of creating the symbolic link is it will work for all users.

You can also create an alias, but that would only work for apps that run as you.

相关阅读:
Top