Iniciar, detener, reiniciar, habilitar y deshabilitar Apache en Linux.
Al instalar Apache en nuestro servidor, este se habilita de forma predeterminada. Pero es evidente que en ciertos momentos necesitemos iniciar, detener, reiniciar, habilitar y deshabilitar Apache.
Estas actuaciones sobre el servidor Apache, varían dependiendo de la distribución Linux que estemos utilizando, también de si hace uso de systemd o no. En este articulo analizamos todas las situaciones posibles.
Iniciar, detener, reiniciar, habilitar y deshabilitar Apache en Linux
Debian, Ubuntu y derivados
Iniciar apache:
sudo systemctl start apache2
Detener apache:
sudo systemctl stop apache2
Reiniciar apache:
sudo systemctl restart apache2
Recargar apache: si solo modificamos un archivo de configuración no es necesario reiniciar apache, podemos hacer un reload.
sudo systemctl reload apache2
Habilitar apache: con este comando habilitamos el inicio automático de apache cuando reinicie el servidor.
sudo systemctl enable apache2
Deshabilitar apache: para deshabilitar el servicio y evitar que se inicie en el arranque del sistema, ejecuta el siguiente comando.
sudo systemctl disable apache2
Estado del servicio:
sudo systemctl status apache2
Rhel, CentOS y derivados
Iniciar apache:
sudo systemctl start httpd
Detener apache:
sudo systemctl stop httpd
Reiniciar apache:
sudo systemctl restart httpd
Recargar apache: si solo modificamos un archivo de configuración no es necesario reiniciar apache, podemos hacer un reload.
sudo systemctl reload httpd
Habilitar apache: con este comando habilitamos el inicio automático de apache cuando reinicie el servidor.
sudo systemctl enable httpd
Deshabilitar apache: para deshabilitar el servicio y evitar que se inicie en el arranque del sistema, ejecuta el siguiente comando.
sudo systemctl disable httpd
Estado del servicio:
sudo systemctl status httpd
ejemplo…
[root@host ~]# systemctl status httpd
● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since vie 2019-09-13 05:15:00 CEST; 3h 29min ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 34156 (httpd)
Status: «Total requests: 11486; Current requests/sec: 1.1; Current traffic: 22KB/sec»
Tasks: 111
Memory: 236.8M
CGroup: /system.slice/httpd.service
├─34156 /usr/sbin/httpd -DFOREGROUND
├─34157 /usr/sbin/httpd -DFOREGROUND
├─34158 /usr/sbin/httpd -DFOREGROUND
├─34159 /usr/sbin/httpd -DFOREGROUND
├─34161 /usr/sbin/httpd -DFOREGROUND
├─34189 /usr/sbin/httpd -DFOREGROUND
└─34501 /usr/sbin/httpd -DFOREGROUND
En sistemas que no utilizan systemd
Iniciar apache:
sudo apachectl start
Detener apache:
sudo apachectl stop
Reiniciar apache:
sudo apachectl restart
Recargar apache: si solo modificamos un archivo de configuración no es necesario reiniciar apache, podemos hacer un reload.
sudo apachectl reload
Habilitar apache: con este comando habilitamos el inicio automático de apache cuando reinicie el servidor.
sudo apachectl enable
Deshabilitar apache: para deshabilitar el servicio y evitar que se inicie en el arranque del sistema, ejecuta el siguiente comando.
sudo apachectl disable
Estado del servicio:
sudo apachectl status
Espero que este articulo te sea de utilidad, puedes ayudarnos a mantener el servidor con una donación (paypal), o también colaborar con el simple gesto de compartir nuestros artículos en tu sitio web, blog, foro o redes sociales.