简体   繁体   English

在 CentOS 上检查 Apache

[英]Checking Apache on CentOS

I am trying to run Apache on my CentOS.(I am having very basic knowledge on linux).我正在尝试在我的 CentOS 上运行 Apache。(我对 linux 有非常基本的了解)。

[Apache Start Stop] using this link i tried to run: apachect1 start But I got -bash apachect1: command not found [Apache Start Stop]使用此链接我尝试运行: apachect1 start但我得到-bash apachect1: command not found

I also tried to check the status using $ /etc/init.d/nginx status But I got -bash: /etc/init.d/nginx: No such file or directory我还尝试使用$ /etc/init.d/nginx status检查$ /etc/init.d/nginx status但我得到了-bash: /etc/init.d/nginx: No such file or directory

Then I tried to check if Apache is installed using : which apache2 But I got /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: 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)

It seems that Apache is not installed, however I can see httpd directory in etc folder.似乎没有安装 Apache,但是我可以在 etc 文件夹中看到 httpd 目录。 Does it have any significance?它有什么意义吗?

Is my assumption correct, if yes how can I install/from where to download & install.我的假设是否正确,如果是,我如何安装/从哪里下载和安装。 Else correct where I am going wrong.其他正确的地方我出错了。

These all the steps will be applied for CentOS 7 and CentOS 8这些所有步骤将适用于 CentOS 7 和 CentOS 8

( Note also apply on RHEL 7/8) 注意也适用于 RHEL 7/8)

I recommend running the below command to auto-remove the unused packages.我建议运行以下命令来自动删除未使用的包。

Step 1:第1步:

yum autoremove

Step 2: Now run the below command to update the CentOS第 2 步:现在运行以下命令来更新 CentOS

  yum update

Step 3: Installing the apache software package第三步:安装apache软件包

yum install httpd

Step 4: Starting the apache service第四步:启动apache服务

The name of the Apache service is httpd. Apache 服务的名称是 httpd。 Use the below command to start and enable it at the same time in CentOS 7 or later version.在 CentOS 7 或更高版本中使用以下命令同时启动和启用它。

systemctl enable --now httpd

Step 5: Checking the httpd service status第五步:检查httpd服务状态

systemctl status httpd

Step 6: Firewall configuration第六步:防火墙配置

As per now, we have to allow the HTTP service in the firewall.现在,我们必须允许防火墙中的 HTTP 服务。 So, you can find the below command useful for that.因此,您可以发现以下命令对此很有用。

firewall-cmd --permanent --add-service http
firewall-cmd --permanent --add-service https

Now reload the firewall service,现在重新加载防火墙服务,

firewall-cmd --reload

Step 7: Test the Apache server.第 7 步:测试 Apache 服务器。 Put the IP address of your computer or the localhost on the web-browser;将您的计算机的 IP 地址或本地主机的 IP 地址放在网络浏览器上; it will show you the Apache server is running.它将显示 Apache 服务器正在运行。

To read more about Apache installation, you can visit my blog post.要阅读有关 Apache 安装的更多信息,您可以访问我的博客文章。 The blog post URL, you can find below.博客文章网址,您可以在下面找到。

LAMP stack installation on CentOS/RHEL 7/8 CentOS/RHEL 7/8 上的 LAMP 堆栈安装

How to install the Apache web-server on CentOS 8 如何在 CentOS 8 上安装 Apache Web 服务器

The best and easiest way to install apache on Centos is using the yum package manager.在 Centos 上安装 apache 的最好和最简单的方法是使用yum包管理器。

Just run the following:只需运行以下命令:

yum install httpd

After installation depending on your Centos version you start the Apache service as follows:根据您的 Centos 版本安装后,您可以按如下方式启动 Apache 服务:

Centos 6 Centos 6

service httpd start

Centos 7 Centos 7

systemctl start httpd

Check if apache is installed检查apache是​​否安装

service httpd status服务 httpd 状态

if the result is "httpd: unrecognized service" , it means not installed.如果结果是"httpd: unrecognized service" ,则表示未安装。

or或者

type your domain or ip in browser, if nothing to displayed, it means no apache installed.在浏览器中输入你的域名或ip,如果没有显示,则表示没有安装apache。

Install Apache安装阿帕奇

yum -y install httpd yum -y 安装httpd

Start Apache service启动Apache服务

service httpd start服务 httpd 启动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM