1. 程式人生 > >手動安裝的ubuntu 裡面的Apache配置多站點模式

手動安裝的ubuntu 裡面的Apache配置多站點模式

1.繫結域名:

vim /etc/hosts

新增域名:

127.0.0.1 www.aaa.com

2.開啟apache的配置檔案httpd.conf

cd /etc/https

vim httpd.conf

找到
#LoadModule rewrite_module modules/mod_rewrite.so

把前面#去掉。沒有則新增,但必選獨佔一行,使apache支援 mod_rewrite 模組

找到:

<Directory "D:/ApacheServer/web">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>


AllowOverride None 換成 AllowOverride All 使apache支援 .htaccess 檔案

設定預設首頁:
找到

DirectoryIndex index.html

在後面新增:
DirectoryIndex index.html index.php

3.繫結域名檔案目錄

cd  /etc/https/extra

vim httpd-vhosts

在檔案的最後新增:

<VirtualHost *:80>
    ServerAdmin lwesite
    DocumentRoot "D:/www/shop/public"
    ServerName shop
    ##ErrorLog "logs/dummy-host2.example.com-error.log"
    ##CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

4.重新啟動Apache:

/usr/local/apache/bin/apachectl restart