侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

CentOS配置虚拟主机virtualhost使服务器支持多网站多域名的方法

linux  /  管理员 发布于 5年前   92

本文实例讲述了CentOS配置虚拟主机virtualhost使服务器支持多网站多域名的方法。分享给大家供大家参考,具体如下:

如何让centos(redhat)配置虚拟主机,让服务器支持多个网站,针对Apache,只需要你修改apache配置文件/etc/httpd/conf/httpd.conf即可。

里面有个example文件,你只要对应配置即可。

#<VirtualHost *:80>#  ServerAdmin [email protected]#  DocumentRoot /www/docs/dummy-host.example.com#  ServerName dummy-host.example.com#  ErrorLog logs/dummy-host.example.com-error_log#  CustomLog logs/dummy-host.example.com-access_log common#</VirtualHos>

你可以参照我的配置,在httpd.conf最底部添加:

NameVirtualHost *:80<VirtualHost *:80>ServerAdmin [email protected] /var/www/htmlServerName www.yourweb.com#ErrorLog /var/log/httpd/yourweb/error_log#注意,这里我设置了以天为单位生产日志ErrorLog "|rotatelogs /var/log/httpd/yourweb/error_log%Y_%m_%d.log 86400 480"#CustomLog /var/log/httpd/yourweb/access_log commonCustomLog "|rotatelogs /var/log/httpd/yourweb/access_log%Y_%m_%d.log 86400 480" common</VirtualHost><VirtualHost *:80>ServerAdmin [email protected] /var/www/html/blogServerName blog.yourweb.comErrorLog /var/log/httpd/blog/error_logCustomLog /var/log/httpd/blog/access_log common</VirtualHost>

如上我配置了两台虚拟主机:域名分别为www.yourweb.com  blog.yourweb.com

注意,重启apache后才生效(service httpd restart)

希望本文所述对大家CentOS服务器管理有所帮助。


  • 上一条:
    Linux find命令实例教程 15个find命令用法
    下一条:
    关于Linux操作系统下终端乱码的完美解决方法
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • Linux中grep命令中的10种高级用法浅析(0个评论)
    • 掌握Linux的xargs命令,效率提升10倍(0个评论)
    • 在Linux系统中如何判断Crontab(定时任务)是否正常执行(1个评论)
    • nginx + keepalived实现高可用示例流程步骤(0个评论)
    • ubuntu 22.04系统中报错:Python 3.6 is no longer supported by the Python core team...解决方式(1个评论)
    • 近期文章
    • docker + gitea搭建一个git服务器流程步骤(0个评论)
    • Laravel 10.34版本发布(0个评论)
    • PHP8中的JIT编译器可以将代码性能提高20%以上(0个评论)
    • 在php语言中实现网站ssl证书过期时间检查功能示例代码(0个评论)
    • 在php语言中实现谷歌登陆功能:google授权api示例代码(0个评论)
    • 在php语言中实现文件加密功能示例(0个评论)
    • 以优雅的方式编写应用程序接口集成和 SDK(0个评论)
    • 在php+laravel项目中使用Saloon扩展包编写API集成(0个评论)
    • Laravel 10.33版本发布(0个评论)
    • 在RabbitMQ种实现批量消费队列数据方法示例(0个评论)
    • 近期评论
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 路人 在

      php中使用hyperf框架调用讯飞星火大模型实现国内版chatgpt功能示例中评论 教程很详细,如果加个前端chatgpt对话页面就完美了..
    • 博主 在

      科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 @ mashrdn 多切换几个节点测试,免费ssr是没那么稳..
    • mashrdn 在

      科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 V2rayn免费节点添加上去了,youtobe无法打开网页,是怎么回事..
    • 2016-11
    • 2017-07
    • 2017-10
    • 2017-11
    • 2018-01
    • 2018-02
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2021-02
    • 2021-03
    • 2021-04
    • 2021-06
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2021-12
    • 2022-01
    • 2022-03
    • 2022-04
    • 2022-08
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-06
    • 2023-07
    • 2023-10
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客