• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Linux: apachectl - Command not found

CrackaLackaZe

Senior member
I can see both httpd and apachectl right there in the directory with my own two eyes. But it keeps giving me a "command not found" message when I try to run it. I've tried ./apachectl and /usr/local/apache2/apachectl and I get the same thing. It used to work before. I'm not sure what happened. The server is running and I need to restart it. Anyone know whats up?
 
Actually, correction.../usr/local/apache2/bin/apachectl works, but why doesn't just typing apachectl from the directory work? How do I fix my path setting?
 
If you want to make something run in a directory that isn't in your path, try putting a ./ before the command. ie... ./apachectl

Joe
 
Originally posted by: Netopia
If you want to make something run in a directory that isn't in your path, try putting a ./ before the command. ie... ./apachectl
Not always. That only works if the executable is in your current directory. The "./" means "current directory".

If you want to change your path, you can do so in your shell startup files. Different distros sometimes handle this in slightly different ways, but it should pretty much always work to add the following line to /home/username/.bashrc:

export PATH="$PATH:/path/to/dir/you/want"

Log out (or close the xterm), and log back in (or open a new xterm) and try echo $PATH to see if your changes worked. If it didn't, try editing /home/username/.bash_profile instead.



 
An alternate solution: put a link in /usr/bin to the apachectl executable. That'd keep your path from getting bloated
 
ok, now for every file that exists in my current directory, I have to type ./[command] to get it to run. How do I make it so all I have to do is type the command from within the directory?
 
Nevermind, I'll just use the "su -" command, and I know what cleverhandle's saying will fix it but I'm not sure I understand how to execute those instructions.
 
Originally posted by: CrackaLackaZe
Nevermind, I'll just use the "su -" command, and I know what cleverhandle's saying will fix it but I'm not sure I understand how to execute those instructions.
Thousands of people before you have been able to change their $PATH... and so can you.

But seriously, if you're going to run a server you really need to understand things like $PATH's, environment variables, and editing config files. If my quick and dirty explanation isn't detailed enough, then search around online for something like "linux command line basics" and find something that suits your temperament better. It's not rocket surgery...
 
generally, you don't want "." to be part of your path because you may end up in some directory that has an executable of the same name as a command that you intended to use and you end up running the wrong thing. many people say that you should always spell out the full path of all executables you run as root to ensure that something like that doesn't happen, but i also know that many people get lazy with that sort of thing.
 
Back
Top