Check for Apache state in Linux

Hi i have a java application that starts/stops/restart Apache and it should also check for its status, so i have looked how checking for status of apache and it appears that you have to check for the state of the service, problem is that when i use

apachectl start

the service httpd is still not started, is that normal ?

i check for the service state by doing

service httpd status

.

[root@lxrdcpsm ~]# service httpd status
httpd is stopped
[root@lxrdcpsm ~]# /apps/apache/2.4.4/bin/apachectl start
httpd (pid 20502) already running
[root@lxrdcpsm ~]# service httpd status
httpd is stopped
[root@lxrdcpsm ~]# /apps/apache/2.4.4/bin/apachectl stop
[root@lxrdcpsm ~]# service httpd status
httpd is stopped
[root@lxrdcpsm ~]# /apps/apache/2.4.4/bin/apachectl start
[root@lxrdcpsm ~]# service httpd status
httpd is stopped
[root@lxrdcpsm ~]# 

2 Answers

Please try the below commands in your terminal..

[root@localhost ~]# service httpd start

OR

 [root@localhost ~]# /etc/init.d/httpd start

After starting it will be running until the system is shut down. While checking status you will get output something like this.

[root@localhost ~]# /etc/init.d/httpd status
httpd (pid 2107) is running...

If you want to start this service automatically on system boot use the below command.

[root@localhost ~]#chkconfig --level 3 httpd on

Where 3 is your current runlevel.

It isn't started because you didn't start it.

Nowadays the new utility responsible for managing services is systemctl and the command to start Apache is

systemctl start httpd

However, one can keep on using the old terminology: service httpd start

Assuming that you want it to start with the system, use the following command:

chkconfig httpd on

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like