[英]Checking Apache on CentOS
我正在尝试在我的 CentOS 上运行 Apache。(我对 linux 有非常基本的了解)。
[Apache Start Stop]使用此链接我尝试运行: apachect1 start
但我得到-bash apachect1: command not found
我还尝试使用$ /etc/init.d/nginx status
检查$ /etc/init.d/nginx status
但我得到了-bash: /etc/init.d/nginx: No such file or directory
然后我尝试使用以下方法检查是否安装了 Apache: which apache2
但是我得到了/usr/bin/which: no apache2 in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/git/bin:/usr/local/git/bin:/home/bebo/bin)
似乎没有安装 Apache,但是我可以在 etc 文件夹中看到 httpd 目录。 它有什么意义吗?
我的假设是否正确,如果是,我如何安装/从哪里下载和安装。 其他正确的地方我出错了。
这些所有步骤将适用于 CentOS 7 和 CentOS 8
(注意也适用于 RHEL 7/8)
我建议运行以下命令来自动删除未使用的包。
第1步:
yum autoremove
第 2 步:现在运行以下命令来更新 CentOS
yum update
第三步:安装apache软件包
yum install httpd
第四步:启动apache服务
Apache 服务的名称是 httpd。 在 CentOS 7 或更高版本中使用以下命令同时启动和启用它。
systemctl enable --now httpd
第五步:检查httpd服务状态
systemctl status httpd
第六步:防火墙配置
现在,我们必须允许防火墙中的 HTTP 服务。 因此,您可以发现以下命令对此很有用。
firewall-cmd --permanent --add-service http
firewall-cmd --permanent --add-service https
现在重新加载防火墙服务,
firewall-cmd --reload
第 7 步:测试 Apache 服务器。 将您的计算机的 IP 地址或本地主机的 IP 地址放在网络浏览器上; 它将显示 Apache 服务器正在运行。
要阅读有关 Apache 安装的更多信息,您可以访问我的博客文章。 博客文章网址,您可以在下面找到。
在 Centos 上安装 apache 的最好和最简单的方法是使用yum
包管理器。
只需运行以下命令:
yum install httpd
根据您的 Centos 版本安装后,您可以按如下方式启动 Apache 服务:
Centos 6
service httpd start
Centos 7
systemctl start httpd
检查apache是否安装
服务 httpd 状态
如果结果是"httpd: unrecognized service" ,则表示未安装。
或者
在浏览器中输入你的域名或ip,如果没有显示,则表示没有安装apache。
安装阿帕奇
yum -y 安装httpd
启动Apache服务
服务 httpd 启动
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.