Starting with apachectl from bash

I am writing a bash file. I need to run apachectlfrom my bash file. so I wrote:

apachectl start

When I run it with the root, an error occurred:

apachectl: command not found

I searched and I found that I should be superuser with su -notsu

Now I want to know:

  • why did this error happen?

  • How can I run it using su?

+5
source share
5 answers

Command error not found because "apachectl" is not in your path. Just use the full path to the command, for example.

/etc/init.d/apachectl start

If you are denied permission, you need to run it as another user. But that is another problem.

+4
source

, $PATH. , , apachectl:

which apachectl

whereis apachectl

- :

/usr/local/sbin/apachectl

, .

+11

find, apachecetl

find / -name apachectl

, status (, find)

/usr/local/sbin/apachectl status

apache,

/usr/local/apache/bin/apachectl restart
+3

, apachectl . , apachectl, PATH . sudo, , sudo, .

+2

httpd, ...

sudo killall -9 httpd

Secondly, find apachectl. Press ctrl + r on the terminal, enter the word "apachectl". Find the path "apachectl".

After selection:

sudo <path>/apachectl stop|start
0
source

All Articles