zoukankan      html  css  js  c++  java
  • [Ubuntu] How to the virtualhost to a path which has many project folder?

    For example, i have there projects folders in

    /var/www/project_1

    /var/www/project_2

    /var/www/project_3

    In a common method, I have to set the virtualhost of the three projects  as:

    <VirtualHost *:80>
        <Directory 
    "/var/www/project_1">
        <
    /Directory>

        DocumentRoot 
    "/var/www/project_1"
        ServerName project_1.myhost
        ServerAlias project_1.myhost
    <
    /VirtualHost>
    <VirtualHost 
    *:80>
        <Directory 
    "/var/www/project_2">
        <
    /Directory>

        DocumentRoot 
    "/var/www/project_2"
        ServerName project_2.myhost
        ServerAlias project_2.myhost
    <
    /VirtualHost>
    <VirtualHost 
    *:80>
        <Directory 
    "/var/www/project_3">
        <
    /Directory>

        DocumentRoot 
    "/var/www/project_3"
        ServerName project_3.myhost
        ServerAlias project_3.myhost

    </VirtualHost> 

    But, the problem comes, how about the new projects coming? Copy and paste the code? No, that is no so clear to do that. We have to find a new way to do it. So how about the code, it help me much la!

    VirtualDocumentRoot /var/www/%1
    <VirtualHost 
    *:80>
       DocumentRoot 
    /var/www
       ServerName myhost

    </VirtualHost> 

    Then i can create any folder in /var/www, then view it directly with the folder name. For example, i create a folder /var/www/test, then i can view it via: http://test.myhost , that is cool! 

  • 相关阅读:
    JavaScript--微博发布效果
    JavaScript--模拟百度搜索下拉li
    JavaScript--for in循环访问属性用"."和[ ]的区别
    JavaScript--函数中()的作用
    JavaScript--时间日期格式化封装
    【网络】Vmware虚拟机下三种网络模式配置
    【IP】DHCP介绍
    【Shell】ps -ef 和ps aux
    【基础】Pipeline
    【时间】Unix时间戳
  • 原文地址:https://www.cnblogs.com/davidhhuan/p/1979848.html
Copyright © 2011-2022 走看看