zoukankan      html  css  js  c++  java
  • ubuntu下配置apache虚拟主机

    服务器IP地址:127.0.0.1:80

    绑定两个 域名 my.cms.com    my.test.com

    将my.cms.com绑定到/home/gaofei/Desktop/www/my_cms

    将my.cms.test绑定到/home/gaofei/Desktop/www/my_test

    1.

    cd /etc/hosts

    添加域名

    127.0.0.1       my.test.com
    127.0.0.1       my.cms.com

    2.进入/etc/apache2/sites-enabled/ ; 删除 000-default 文件。

    3.在/etc/apache2/sites-available/ 下建立两个文件 名为 my.test.com     my.cms.com

    在my.cms.com插入以下内容

    <VirtualHost *:80>
     ServerAdmin webmaster@localhost
     ServerName my.cms.com
     DocumentRoot /home/gaofei/Desktop/www/my_cms
     <Directory />
      Options FollowSymLinks
      DirectoryIndex index.php index.html index.htm
      AllowOverride None
     </Directory>
     <Directory /home/gaofei/Desktop/www/my_cms>
    # Options Indexes FollowSymLinks MultiViews
      Options FollowSymLinks
      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . index.php
      AllowOverride All
      Order allow,deny
      allow from all
     </Directory>
    
     ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
     <Directory "/usr/lib/cgi-bin">
      AllowOverride None
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      Order allow,deny
      Allow from all
     </Directory>
    
     ErrorLog ${APACHE_LOG_DIR}/error.log
    
     # Possible values include: debug, info, notice, warn, error, crit,
     # alert, emerg.
     LogLevel warn
    
     CustomLog ${APACHE_LOG_DIR}/access.log combined
    
        Alias /doc/ "/usr/share/doc/"
        <Directory "/usr/share/doc/">
     Options Indexes MultiViews FollowSymLinks
     AllowOverride None
     Order deny,allow
         Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
    </VirtualHost>

    在my.test.com内插入以下内容

    <VirtualHost *:80>
     ServerAdmin webmaster@localhost
     ServerName my.test.com
     DocumentRoot /home/gaofei/Desktop/www/my_test
     <Directory />
      Options FollowSymLinks
      DirectoryIndex index.php index.html index.htm
      AllowOverride None
     </Directory>
     <Directory /home/gaofei/Desktop/www/my_test>
    # Options Indexes FollowSymLinks MultiViews
      Options FollowSymLinks
      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . index.php
      AllowOverride All
      Order allow,deny
      allow from all
     </Directory>
    
     ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
     <Directory "/usr/lib/cgi-bin">
      AllowOverride None
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      Order allow,deny
      Allow from all
     </Directory>
    
     ErrorLog ${APACHE_LOG_DIR}/error.log
    
     # Possible values include: debug, info, notice, warn, error, crit,
     # alert, emerg.
     LogLevel warn
    
     CustomLog ${APACHE_LOG_DIR}/access.log combined
    
        Alias /doc/ "/usr/share/doc/"
        <Directory "/usr/share/doc/">
     Options Indexes MultiViews FollowSymLinks
     AllowOverride None
     Order deny,allow
         Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
    </VirtualHost>

    4.在 /etc/apache2/sites_enabled/ 中创建ln链接:

    ln -s   /etc/apache2/sites-available/my.test.com /etc/apache2/sites-enabled/my.test.com
    ln -s   /etc/apache2/sites-available/my.cms.com /etc/apache2/sites-enabled/my.cms.com

    5.重启apache2

    service apache2 restart
  • 相关阅读:
    http学习笔记(一)
    关于花瓣网header条的思考
    前端知识体系之入门篇总结(一)
    浮动理解【转】
    CSS选择器比较:queryselector queryselectorall
    javascript模块化
    【C#】 Stopwatch详解
    ArcGIS图层添加字段出现:“定义了过多字段”
    [SWMM]出现问题及解决
    ArcGIS:从DEM数据提取对应点的高程
  • 原文地址:https://www.cnblogs.com/g825482785/p/apachevhost.html
Copyright © 2011-2022 走看看