Restarting apache in linux

Содержание
  1. Как запустить, остановить или перезапустить Apache
  2. Подготовка
  3. Запуск, остановка и перезапуск Apache в Ubuntu и Debian
  4. Запуск, остановка и перезапуск Apache на RHEL / CentOS
  5. Выводы
  6. Start / Stop and Restart Apache 2 Web Server Command
  7. Debian/Ubuntu Linux Specific Commands to Start/Stop/Restart Apache
  8. Restart Apache 2 web server, enter:
  9. To stop Apache 2 web server, enter:
  10. To start Apache 2 web server, enter:
  11. A note about Debian/Ubuntu Linux systemd users
  12. CentOS/RHEL (Red Hat) Linux version 4.x/5.x/6.x or older specific commands
  13. CentOS/RHEL (Red Hat) Linux version 7.x or newer specific commands
  14. Alpine Linux start / stop / restart Apache 2 using openrc
  15. FreeBSD Unix users
  16. Generic method to start/stop/restart Apache on a Linux/Unix
  17. Summing up
  18. Как остановить и перезапустить Apache в Linux-системах
  19. На Ubuntu/Debian Linux
  20. Apache2 Restart/Start/Stop/
  21. На RHEL/CentOS
  22. Apache2 Restart/Start/Stop
  23. Для более старых версий (CentOS / RHEL (Red Hat) Linux версии 4.x / 5.x / 6.x)
  24. В Fedora Apache2 Перезагрузка / Запуск / остановка
  25. Ubuntu Linux: Start / Restart / Stop Apache Web Server
  26. Method #1: systemctl command examples
  27. Method #2: /etc/init.d/apache2 command examples
  28. Task: Start Apache 2 Server
  29. Task: Restart Apache 2 Server
  30. Task: Stop Apache 2 Server
  31. Method #3: service command examples
  32. Method #4: upstart command examples
  33. Method #5: apache2ctl command examples

Как запустить, остановить или перезапустить Apache

Apache — это кроссплатформенный HTTP-сервер с открытым исходным кодом. Он обладает мощными функциями и может быть расширен с помощью большого количества модулей.

Если вы разработчик или системный администратор, скорее всего, вы имеете дело с Apache на регулярной основе.

Запуск, остановка и перезапуск / перезагрузка являются наиболее распространенными задачами при работе с веб-сервером Apache. Команды для управления службой Apache различны в разных дистрибутивах Linux.

Большинство последних дистрибутивов Linux используют SystemD в качестве системы инициализации и диспетчера служб по умолчанию. Старые дистрибутивы основаны на SysVinit и используют сценарии инициализации для управления службами. Еще одно отличие — это название сервиса. В Ubuntu и Debian служба Apache называется apache2 , а в системе на основе Red Hat, такой как CentOS, имя службы — httpd .

В этой статье объясняется, как запустить, остановить и перезапустить Apache в наиболее популярных дистрибутивах Linux.

Подготовка

В инструкциях предполагается, что вы вошли в систему как пользователь root или пользователь с привилегиями sudo .

И служебные блоки SystemD, и сценарий SysVinit принимают следующие аргументы для управления службой Apache:

  • start : start службу Apache.
  • stop : завершает работу службы Apache.
  • restart : останавливает, а затем запускает службу Apache.
  • reload : аккуратно перезапускает службу Apache. При перезагрузке основной процесс Apache завершает дочерние процессы, загружает новую конфигурацию и запускает новые дочерние процессы.
  • status : показывает статус услуги.

Запуск, остановка и перезапуск Apache в Ubuntu и Debian

SystemD — это системный и сервисный менеджер для последних выпусков Ubuntu ( 20.04 18.04 ) и Debian ( 10 , 9 ).

Чтобы запустить службу Apache, выполните следующую команду:

Чтобы остановить службу Apache, выполните следующую команду:

Каждый раз, когда вы вносите изменения в конфигурацию Apache, вам необходимо перезапускать серверные процессы. Чтобы перезапустить службу Apache, запустите:

Более старые (EOLed) версии Ubuntu или Debian используют сценарии init.d для запуска, остановки и перезапуска демона Apache:

Запуск, остановка и перезапуск Apache на RHEL / CentOS

Systemd — это системный и сервисный менеджер для RHEL / CentOS 7 и 8 .

Запустите службу Apache:

Остановите службу Apache:

Перезапустите службу Apache:

Если у вас есть система CentOS 6 или более ранней версии, которая использует SysV, используйте следующие команды для запуска, остановки и перезапуска демона Apache:

Выводы

Мы показали вам, как запускать, останавливать и перезапускать веб-сервер Apache в различных системах Linux.

Если у вас есть какие-либо вопросы или отзывы, не стесняйтесь оставлять комментарии ниже.

Источник

Start / Stop and Restart Apache 2 Web Server Command

H ow do I restart an Apache 2 Web Server under a Debian / Ubuntu / CentOS / RHEL / Fedora Linux or UNIX-like operating systems? Can you tell me command to start or stop Apache 2 web server running on Linux?

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Apache 2 on Linux / Unix
Est. reading time 3 mintues

Apache is primarily used to serve both static content and dynamic Web pages on the World Wide Web. Many web applications are designed expecting the environment and features that Apache provides. Apache can be started or restarted using any one of the following methods on Linux or Unix-like systems.

First, login to your web-server using ssh client, if server is not in your local data center:
ssh root@your.server.com
Once logged in type the following commands as per your Linux or Unix variant.

Debian/Ubuntu Linux Specific Commands to Start/Stop/Restart Apache

You can either use service or /etc/init.d/ command as follows on Debian Linux version 7.x or Ubuntu Linux version Ubuntu 14.10 or older:

Restart Apache 2 web server, enter:

# /etc/init.d/apache2 restart
OR
$ sudo /etc/init.d/apache2 restart
OR
$ sudo service apache2 restart

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

To stop Apache 2 web server, enter:

# /etc/init.d/apache2 stop
OR
$ sudo /etc/init.d/apache2 stop
OR
$ sudo service apache2 stop

To start Apache 2 web server, enter:

# /etc/init.d/apache2 start
OR
$ sudo /etc/init.d/apache2 start
OR
$ sudo service apache2 start

A note about Debian/Ubuntu Linux systemd users

Use the following systemctl command on Debian Linux version 8.x+ or Ubuntu Linux version Ubuntu 15.04+ or above:
## Start command ##
systemctl start apache2.service
## Stop command ##
systemctl stop apache2.service
## Restart command ##
systemctl restart apache2.service
We can view status using the following command:
$ sudo systemctl status apache2.service

CentOS/RHEL (Red Hat) Linux version 4.x/5.x/6.x or older specific commands

## Start ##
service httpd start
## Stop ##
service httpd stop
## Restart ##
service httpd restart

CentOS/RHEL (Red Hat) Linux version 7.x or newer specific commands

Most modern distro now using systemd, so you need to use the following systemctl command:
## Start command ##
systemctl start httpd.service
## Stop command ##
systemctl stop httpd.service
## Restart command ##
systemctl restart httpd.service

Alpine Linux start / stop / restart Apache 2 using openrc

We need to use the service command as root user:
# service apache2 start
# service apache2 stop
# service apache2 status
# service apache2 restart
Session:

FreeBSD Unix users

FreeBSD user can restart Apache as follows:
# /usr/local/etc/rc.d/apache22 restart
# service restart apache22
# service stop apache22
# service start apache22

Generic method to start/stop/restart Apache on a Linux/Unix

The syntax is as follows (must be run as root user):
## stop it ##
apachectl -k stop
## restart it ##
apachectl -k restart
## graceful restart it ##
apachectl -k graceful
## Start it ##
apachectl -f /path/to/your/httpd.conf
apachectl -f /usr/local/apache2/conf/httpd.conf

Summing up

You learned how to start, stop or restart the Apache 2 web server using command-line over ssh-based session.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

Как остановить и перезапустить Apache в Linux-системах

Как мы все знаем, Apache – это бесплатный кросс-платформенный веб-сервер с открытым исходным кодом, который используется как для статических, так и для динамических веб-страниц.

В этой статье мы остановимся на том, как вы можете запускать и перезапускать веб-сервер Apache в системах Linux с помощью команды apache2.

На Ubuntu/Debian Linux

Давайте посмотрим, как мы можем запустить, остановить и перезапустить веб-сервер apache2 в версиях Ubuntu и Debian

Apache2 Restart/Start/Stop/

Для пользователей Ubuntu и Debian Systemd – Ubuntu 18.04,16.04 и Debian 9.x используются команды ниже:

Запустите Apache2, запустив

Остановите Apache2, запустив

Перезапустите Apache2, запустив

Проверка состояния Apache2:

Чтобы проверить, действительно ли веб-сервер работает, откройте свой браузер и введите IP-адрес своего сервера

Вы должны иметь возможность просматривать страницу Apache по умолчанию, как показано ниже:

Для более старых версий Ubuntu -14.10 и старше, и Debian

Запустите службу Apache2, запустив

Остановите службу Apache2, запустив

Проверка состояния Apache2

На RHEL/CentOS

Apache2 Restart/Start/Stop

Для более новых версий RHEL / CentOS (версии 7.x и выше)

Запустите Apache2, запустив

Остановите Apache2, запустив

Перезапустите Apache2, запустив

Чтобы проверить статус Apache2

Для более старых версий (CentOS / RHEL (Red Hat) Linux версии 4.x / 5.x / 6.x)

Запустите Apache2, запустив

Остановите Apache2, запустив

Перезапустите Apache2, запустив

Чтобы проверить статус веб-сервера Apache

Как и в системах Debian, вы можете проверить, работает ли веб-сервер, открыв браузер и набрав IP-адрес вашего сервера

В Fedora
Apache2 Перезагрузка / Запуск / остановка

На Fedora 22. и более поздних

Запуск вебсервера Apache:

Остановите Apache2, запустив

Чтобы перезапустить Apache2

Чтобы проверить статус Apache2

Чтобы подтвердить, что сервер запущен и поднят в веб-браузере, введите IP-адрес сервера

Источник

Ubuntu Linux: Start / Restart / Stop Apache Web Server

H ow do I start, restart, or stop Apache 2.x web server on Ubuntu Linux operating systems using command line options?

You can use any one of the following method to restart / start / stop your Apache (httpd) sever on Ubuntu:

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Shell
Est. reading time 1m
  1. systemctl command – Only works on systemd based Ubuntu like version 16.04 LTS and above.
  2. /etc/init.d/apache2 – A sys v init style script to start / stop / restart the Apache2 service under Debian or Ubuntu Linux.
  3. service command – This command work in most Linux distributions including Debian and Ubuntu.
  4. upstart command – Only works on certain version of Ubuntu.
  5. apache2ctl command – This method should work on all Linux and Unix like operating systems.

Method #1: systemctl command examples

To start Apache 2 on Ubuntu Linux LTS 16.04 LTS or the latest systemd based Ubuntu Linux, type:
$ sudo systemctl start apache2.service
To stop Apache 2 on Ubuntu Linux LTS 16.04 LTS or the latest systemd based Ubuntu Linux, type:
$ sudo systemctl stop apache2.service
To restart Apache 2 on Ubuntu Linux LTS 16.04 LTS or the latest systemd based Ubuntu Linux, type:
$ sudo systemctl restart apache2.service
To status of start/restart/stop operation, enter:
$ journalctl -u apache2
To find out whether Apache 2 running or not, enter:
$ sudo systemctl status apache2.service
Sample session:

Fig.01: Ubuntu Linux systemctl start/stop/restart Apache server (systemd)

Method #2: /etc/init.d/apache2 command examples

You need to login as root user or use the sudo command to control Apache web-server.

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Task: Start Apache 2 Server

# /etc/init.d/apache2 start
or
$ sudo /etc/init.d/apache2 start

Task: Restart Apache 2 Server

# /etc/init.d/apache2 restart
or
$ sudo /etc/init.d/apache2 restart

Task: Stop Apache 2 Server

# /etc/init.d/apache2 stop
or
$ sudo /etc/init.d/apache2 stop

Method #3: service command examples

To restart Apache 2, enter:
$ sudo service apache2 restart
To stop Apache 2, enter:
$ sudo service apache2 stop
To start Apache 2, enter:
$ sudo service apache2 start
To gracefully reload Apache 2, enter:
$ sudo service apache2 reload

Method #4: upstart command examples

The following commands only works with certian version of Ubuntu such as Ubuntu Linux LTS 12.04 and 14.04. To start Apache 2 on Ubuntu, run:
$ sudo start apache2
To stop Apache 2 on Ubuntu, run:
$ sudo stop apache2
To restart Apache 2 on Ubuntu, run:
$ sudo restart apache2
To gracefully reload Apache 2 on Ubuntu, run:
$ sudo restart apache2

Method #5: apache2ctl command examples

apache2ctl is Apache HTTP server control interface command, which can be used to stop or start web server under any Linux distribution or UNIX.
To start Apache 2 on Ubuntu, type:
$ sudo apache2ctl start
To stop Apache 2 on Ubuntu, type:
$ sudo apache2ctl stop
To restart Apache 2 on Ubuntu, type:
$ sudo apache2ctl restart
To gracefully reload Apache 2 on Ubuntu, type:
$ sudo apache2ctl graceful

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

/.bash_profile and add:
alias apache=’sudo /etc/init.d/apache2′

Then it’s just apache start, apache restart, etc.

Thanks for the tip. It worked like a charm.

These cmd line works great.

Here is what works for me:

/etc/rc.d/init.d/httpd (space) start

/etc/rc.d/init.d/httpd (space) stop

nice tutorials,
is there a way to run the apache server as services just like in xampp?
Thanks,
man

wohooooooo. good tutorial . 4 thumbs ^_^

it s not workin for me….
the result is
sudo: /etc/init.d/apache2 commad not found
pls help me guys

sudo /etc/init.d/apache2 do not put that column after sudo

i has stop my apache server, but another connections still establish

unix 3 [ ] STREAM CONNECTED 14940 /tmp/orbit-username/

I’m from Brazil, and your tip helped me a lot, thanks!

sudo service apache2 restart

Thanks mate! nice and easy ( I like the easy ones!)

Thanks for the help.

the amount of times i forget this. sheesh. thanks gzip

Hi! this tutorial is great. things have been ok but mine didnt work at the configuration stage. i restart the server but this d response:
Restarting web server apache2 apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
… waiting apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
help me pls

Your can also use this command
sudo service apache2 restart

Does the “sudo service apache2” apply for the php cli ?

PHP Cli uses a different php.ini .

sudo service apache2 This worked for me, thanks a lot. I had an instance of apache2 running, but it was screwing up apache that was trying to run in xampp.

Nice tutorial. Help a lot 🙂

If you get “command not found” then apache2 may have been installed in a non-standard directory. For instance the bitnami installers put it in ‘stack’, so to find the ctl.sh you may need to use

sudo stack/apache2/scripts/ctl.sh restart

Whether this actually solves your problem or not, I don’t know, but it doesn’t cause the error.

Also when using bitnami the command

sudo stack/ctlscript.sh restart

restarts every service bitnami installed, including apache, in a logical order.

Final comment on this: If you are using one of the XAMPP or other stacks that installs apache as part of a larger package, you want to watch the stack-restart command (like the one I gave above for bitnami) very closely and always get the verbose log.

If you have made some change like blowing away an app directory you aren’t using to fit within tight cloud host requirements, the configuration files generated for apache may be wrong/fragile and may cause apache to just not start with no indication why. However the stack-restart command for the stack you are using will generally report that problem. For instance in bitnami the restart is fragile – unless every single line of the configuration files it is relying on is up to date, you’ll have to go edit them yourself

sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf

PHP is however more robust and usually only generates a warning if it doesn’t find some app configuration include. The worst you will see from PHP is a line like this

WARNING: Nothing matches the include pattern ‘/opt/bitnami/apps/limesurvey/conf/php-fpm/pool.conf’ from /opt/bitnami/php/etc/php-fpm.conf at line 17.

so you can sudo nano that .conf file also, but it might be better to let all future shell users have at least a chance to notice that you blew away an app package and then manually reconfigured. I would leave the warnings in place myself. Your mileage may vary.

why we have to restart apache server in ubantu

## How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 14.04

$ sudo apt-get update
$ sudo apt-get install apache2

Источник

Читайте также:  Открывается окно безопасность windows
Оцените статью