zoukankan      html  css  js  c++  java
  • linux系统配置Apache虚拟主机实例

    安装apache,php: yum install httpd php 假设VPS的IP是58.130.17.168,有两个域名指向该IP,分别是domain1.com, domain2.com, 修改/etc/httpd/conf/httpd.conf,在文件的最后加入: ServerName 58.130.17.168 NameVirtualHost 58.130.17.168 &

    安装apache,php:
    yum install httpd php

    假设VPS的IP是58.130.17.168,有两个域名指向该IP,分别是domain1.com, domain2.com,

    修改/etc/httpd/conf/httpd.conf,在文件的最后加入:

    ServerName 58.130.17.168
    NameVirtualHost 58.130.17.168

    <VirtualHost 58.130.17.168>
            ServerName domain1.com
            DocumentRoot /var/www/domain1.com
            <Directory "/var/www/domain1.com">
                Options Indexes FollowSymLinks
                AllowOverride None
                Order allow,deny
                Allow from all
            </Directory>
    </VirtualHost>

    <VirtualHost 58.130.17.168>
            ServerName domain2.com
            DocumentRoot /var/www/domain2.com
            <Directory "/var/www/domain2.com">
                Options Indexes FollowSymLinks
                AllowOverride None
                Order allow,deny
                Allow from all
            </Directory>
    </VirtualHost>

    然后在/var/www/domain1.com和/var/www/domain2.com下创建不同的index.html文件:
    echo "domain1">/var/www/domain1.com/index.html
    echo "domain2">/var/www/domain2.com/index.html

    在浏览器里输入http://domain1.com和http://domain2.com即可看到效果了

  • 相关阅读:
    沈询:事务与分布式事务原理与实现
    c++ 幕客网
    Meet Dgraph — an open source, scalable, distributed, highly available and fast graph databas
    开发与系统管理----开发工具 左蓝
    奇虎360技术博客
    java 相关软件使用趋势
    长亭技术专栏 安全攻防技术分享
    tcp/ip RFC
    gentoo and arclinux
    孙鑫视频VC++深入详解学习笔记
  • 原文地址:https://www.cnblogs.com/tblog/p/4694012.html
Copyright © 2011-2022 走看看