在 Linux 上启动 Apache 的命令

如何启动 Apache Web 服务器

如果 Apache 在本地机器上,我们可以按原样运行这些命令,否则我们将需要使用 SSH 或者 Telnet 远程访问服务器。
例如, ssh root@server1.onitroad.com 将通过 SSH 连接到 Apache 服务器。

根据 Linux 版本,启动 Apache 的步骤略有不同:

通用 Apache 启动命令

这些通用命令应该在任何 Linux 发行版上启动 Apache:

$ sudo apachectl start
$ sudo apache2ctl start
$ sudo apachectl -f /path/to/your/httpd.conf
$ sudo apachectl -f /usr/local/apache2/conf/httpd.conf

适用于 Red Hat、Fedora 和 CentOS

4.x、5.x、6.x 或者更早的版本应该使用这个命令:

$ sudo service httpd start

对 7.x 或者更高版本使用此命令:

$ sudo systemctl start httpd.service

如果这些不起作用,请尝试以下命令:

$ sudo /etc/init.d/httpd start

Debian 和 Ubuntu

将此命令用于 Debian 8.x 或者更新版本和 Ubuntu 15.04 及更高版本:

$ sudo systemctl start apache2.service

Ubuntu 12.04 和 14.04 可能需要以下命令:

$ sudo start apache2

如果这些不起作用,请尝试以下方法之一:

$ sudo /etc/init.d/apache2 start
$ sudo service apache2 start
日期:2020-07-15 11:16:30 来源:oir作者:oir