温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Centos8中如何部署Apache虚拟机

发布时间:2022-02-17 10:20:25 来源:亿速云 阅读:221 作者:iii 栏目:开发技术

这篇文章主要介绍了Centos8中如何部署Apache虚拟机的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Centos8中如何部署Apache虚拟机文章都会有所收获,下面我们一起来看看吧。

实验环境

操作系统:Centos 8

web应用:apache

内网IP:192.168.3.21

shell执行:root

Centos8中如何部署Apache虚拟机

以root或具有sudo权限的用户身份登录执行如下操作。

安装httpd服务

[root@linuxcool ~]# yum install httpd-devel.x86_64 httpd.x86_64 httpd-tools.x86_64

验证httpd是否安装成功

[root@linuxcool ~]# httpd -vServer version: Apache/2.4.6 (CentOS)
Server built:   Apr  2 2020 13:13:23

启动httpd服务

[root@linuxcool ~]# systemctl start httpd.service     
[root@linuxcool ~]# systemctl status httpd.service● httpd.service - The Apache HTTP Server
  Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
  Active: active (running) since Fri 2020-05-22 12:23:03 CST; 25s ago
    Docs: man:httpd(8)
          man:apachectl(8)
Main PID: 952 (httpd)
  Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"   Tasks: 6
  Memory: 3.6M
  CGroup: /system.slice/httpd.service
          ├─952 /usr/sbin/httpd -DFOREGROUND
          ├─953 /usr/sbin/httpd -DFOREGROUND
          ├─954 /usr/sbin/httpd -DFOREGROUND
          ├─955 /usr/sbin/httpd -DFOREGROUND
          ├─956 /usr/sbin/httpd -DFOREGROUND
          └─957 /usr/sbin/httpd -DFOREGROUND

May 22 12:23:03 linuxcool systemd[1]: Starting The Apache HTTP Server...
May 22 12:23:03 linuxcool httpd[952]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, u...message
May 22 12:23:03 linuxcool systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

apache安装成功,默认web目录/var/www/

测试

http://192.168.3.21/
Centos8中如何部署Apache虚拟机

安装成功!

配置apache虚拟主机

创建网站目录

[root@linuxcool ~]# mkdir -p /var/www/web1[root@linuxcool ~]# mkdir -p /var/www/web2

web1添加index.html

[root@linuxcool ~]# vim /var/www/web1/index.htmlnbsp;html>
"ltr">
 
   "utf-8">
   Welcome to Web1 
 
   Success! Web1 home page!

web2添加index.html

[root@linuxcool ~]# vim /var/www/web2/index.htmlnbsp;html>
"ltr">
 
   "utf-8">
   Welcome to Web2 
 
   Success! Web2 home page!

授权web目录权限

[root@linuxcool ~]# chown -R apache: /var/www/web1/[root@linuxcool ~]# chown -R apache: /var/www/web2/

创建虚拟主机文件

#web1

[root@linuxcool ~]# vim /etc/httpd/conf.d/web1.confServerName web1.comServerAlias www.web1.comServerAdmin webmaster@example.comDocumentRoot /var/www/web1Options -Indexes +FollowSymLinksAllowOverride AllErrorLog /var/log/httpd/example.com-error.logCustomLog /var/log/httpd/example.com-access.log combined

#web2

[root@linuxcool ~]# vim /etc/httpd/conf.d/web2.confServerName web2.comServerAlias www.web2.comServerAdmin webmaster@example.comDocumentRoot /var/www/web2Options -Indexes +FollowSymLinksAllowOverride AllErrorLog /var/log/httpd/example.com-error.logCustomLog /var/log/httpd/example.com-access.log combined

重启httpd服务

[root@linuxcool ~]# systemctl restart httpd.service

验证httpd虚拟主机结果

http://www.web1.com

Centos8中如何部署Apache虚拟机

http://www.web2.com

Centos8中如何部署Apache虚拟机

关于“Centos8中如何部署Apache虚拟机”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“Centos8中如何部署Apache虚拟机”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI