Starting httpd on linux

How To Start / Stop / Restart / Enable / Reload The Apache (HTTPD) Service In Linux?

systemd is a new system and service manager for Linux system, which was implemented/adapted into all the major Linux distributions over the traditional SysV init systems due to lots of issue/improvement has to be on SysVinit systems.

All the service files are available on /etc/init.d/ directory for SysVinit system.

For systemd system, the service files are available on /usr/lib/systemd/system/ directory.

If you would like to perform any kind of actions like start, stop, restart, enable, reload & status against the specific service then use the following commands.

Make sure that you should have admin privileges to run these commands except status command. It should be root or sudo permission needed to run the below commands.

1) How To Start The Apache (httpd) Service In Linux?

Use the below commands to start the Apache (httpd) server in Linux.

For SysVinit Systems – openSUSE & Debian based systems.

# service apache2 start or # /etc/init.d/apache2 start

For SysVinit Systems – RHEL (RedHat) based systems.

# service httpd start or # /etc/init.d/httpd start

For systemd Systems – openSUSE & Debian based systems.

# systemctl start apache2.service or # systemctl start apache2

For systemd Systems – RHEL (RedHat) based systems.

# systemctl start httpd or # systemctl start httpd.service

2) How To Stop The Apache (httpd) Service In Linux?

Use the below commands to stop the Apache (httpd) server in Linux.

For SysVinit Systems – openSUSE & Debian based systems.

# service apache2 stop or # /etc/init.d/apache2 stop

For SysVinit Systems – RHEL (RedHat) based systems.

# service httpd stop or # /etc/init.d/httpd stop

For systemd Systems – openSUSE & Debian based systems.

# systemctl stop apache2.service or # systemctl stop apache2

For systemd Systems – RHEL (RedHat) based systems.

# systemctl stop httpd or # systemctl stop httpd.service

3) How To Restart The Apache (httpd) Service In Linux?

Use the below commands to restart the Apache (httpd) server in Linux.

For SysVinit Systems – openSUSE & Debian based systems.

# service apache2 restart or # /etc/init.d/apache2 restart

For SysVinit Systems – RHEL (RedHat) based systems.

# service httpd restart or # /etc/init.d/httpd restart

For systemd Systems – openSUSE & Debian based systems.

# systemctl restart apache2.service or # systemctl restart apache2

For systemd Systems – RHEL (RedHat) based systems.

# systemctl restart httpd or # systemctl restart httpd.service

4) How To Reload The Apache (httpd) Service In Linux?

Use the below commands to reload the Apache (httpd) server in Linux.

Читайте также:  Установка пакетов линукс вручную

For SysVinit Systems – openSUSE & Debian based systems.

# service apache2 reload or # /etc/init.d/apache2 reload

For SysVinit Systems – RHEL (RedHat) based systems.

# service httpd reload or # /etc/init.d/httpd reload

For systemd Systems – openSUSE & Debian based systems.

# systemctl reload apache2.service or # systemctl reload apache2

For systemd Systems – RHEL (RedHat) based systems.

# systemctl reload httpd or # systemctl reload httpd.service

5) How To View The Apache (httpd) Service Status In Linux?

Use the below commands to view the Apache (httpd) server status in Linux.

For SysVinit Systems – openSUSE & Debian based systems.

# service apache2 status or # /etc/init.d/apache2 status

For SysVinit Systems – RHEL (RedHat) based systems.

# service httpd status or # /etc/init.d/httpd status

For systemd Systems – openSUSE & Debian based systems.

# systemctl status apache2.service or # systemctl status apache2

For systemd Systems – RHEL (RedHat) based systems.

# systemctl status httpd or # systemctl status httpd.service

6) How To Enable The Apache (httpd) Service On Boot In Linux?

Use the below commands to enable the Apache (httpd) server on boot in Linux.

For SysVinit Systems – openSUSE & Debian based systems.

For SysVinit Systems – RHEL (RedHat) based systems.

For systemd Systems – openSUSE & Debian based systems.

# systemctl enable apache2.service or # systemctl enable apache2

For systemd Systems – RHEL (RedHat) based systems.

# systemctl enable httpd or # systemctl enable httpd.service

Источник

Как запустить, остановить или перезапустить 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 : показывает статус услуги.
Читайте также:  Oracle linux установка ssh

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

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

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

sudo systemctl start apache2

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

sudo systemctl stop apache2

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

sudo systemctl restart apache2

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

sudo service apache2 startsudo service apache2 stopsudo service apache2 restart

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

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

sudo systemctl start httpd
sudo systemctl stop httpd

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

sudo systemctl restart httpd

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

sudo service httpd startsudo service httpd stopsudo service httpd restart

Выводы

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

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

Источник

How to Start, Stop, or Restart Apache Server on CentOS 7

Apache is part of the popular LAMP (Linux, Apache, MySQL, PHP) stack of software. It’s responsible for the function of most of the internet.

This guide will show you how to restart Apache service on Linux CentOS 7.

how to start, stop, or restart apache server on centos7

  • Access to a user account with sudo privileges
  • An installed and configured Apache installation
  • Access to a command line / terminal window (Menu > Applications > Utilities > Terminal)

Restarting Apache on CentOS 7

Method 1: Restart Apache Server Using Systemctl Command

Open a terminal window and enter the following:

sudo systemctl restart httpd.service

The service should restart.

The restart command can take several moments to complete, depending on the complexity of your server configuration. If you’re running a large or complex server configuration, this can cause disruptions for users who rely on the server.

Method 2: Restart HTTPD Server Using Apachectl Command Script

Apache recommends using a control script to pass commands to the httpd process.

To restart Apache in this manner, enter the following:

To instruct the Apache service to terminate all child processes and itself, run the following command:

Use the below-mentioned command to exit child processes after they finish a task and then launch new instances. The service will reload configuration files as well.

Use -k restart to force child processes to exit. The parent process stays running, and reloads configuration files.

Use -k graceful-stop to force parent process to stop child processes as they complete their tasks. Once all child processes are stopped, the parent process exits.

Читайте также:  Как kali linux сделать на весь экран в virtualbox

For more information on the apachectl command, see the Apache documentation.

Other Commands to Use with Systemctl

To start the Apache service:

sudo systemctl start httpd.service

Stop the Apache service with:

sudo systemctl stop httpd.service

Force Apache to refresh the configuration files:

sudo systemctl reload httpd.service

Set Apache to run when the system boots:

sudo systemctl enable httpd.service

Prevent Apache from loading when the system boots:

sudo systemctl disable httpd.service

The reload command is faster and creates much less disruption than restart. However, this only performs a soft refresh of the configuration files. Some services and dependencies may not be included in the refresh.

One good practice is to weigh the benefits against the costs of each process. If you have several clients depending on access to your server, try to refresh first. If that doesn’t work, or if the disruption is minimal, use restart.

Apache Best Practices

Like many Linux services, Apache’s functionality can be modified using configuration files and modules. Configuration files should all be stored in the /etc/httpd/ directory.

In that directory, look for the /httpd.conf file – this is the main configuration file for Apache’s global settings. You can edit this file with any text editor to change your Apache configuration.

Apache’s functionality can be enhanced using modules. A module is an application that works in conjunction with the main Apache application. For example, the mod_bandwidth module allows you to set a bandwidth limit on each connection.

Available modules can be found in the /etc/httpd/mods-available directory.

Use the following commands to manage modules:

You can configure Apache to listen on specific ports by editing the /etc/apache2/ports.conf file.

Apache creates log files during usage. The error log reports any problems, misconfigurations, or other issues. You can use the error log to find issues with your configuration.

The access log tracks every client that connects to your Apache server. This can be used to view resources being used or how users interact with your website.

Apache access and error log files can grow large as they record so much data. Most users will use a tool like tail or cat to display a portion of the log file.

As Apache runs, the log files will use more disk space. To keep them manageable, Apache recommends rotating log files and using the graceful restart option above.

Apache can manage multiple websites, called virtual hosts, on the same system. Content is stored in the /var/www/ directory.

Available sites are stored in /etc/httpd/sites-available , and enabled sites are stored in /etc/httpd/sites-enabled.

Starting, stopping, & restarting the Apache service is relatively straightforward. You can use additional commands to customize your particular configuration.

For example, you might choose to reload Apache instead of a full restart. Or, you might use the apachectl command for more control over your server.

Источник

Оцените статью
Adblock
detector