a2ensite的使用方法
时间:2006-08-22 来源:nothing9
First, create a subdirectory of /var/www/ to contain the site. It makes sense to name this directory after the domain that will live there.
$> mkdir /var/www/mydomain.com
Now create the subdirectory /var/www/mydomain.com/docs/. This will be the only directory that is publicly accessible.
$> mkdir /var/www/mydomain.com/docs
Now create /var/www/mydomain.com/docs/index.html, something simple like the following:
<html>
<head>
<title>Mydomain.com test index page</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
Now create /etc/apache2/sites-available/mydomain.com. We use the <VirtualHost> directive to define the virtual site, and the <Directory> directive to define the ...xxx/docs/ directory as publicly accessible (Allow from all). Like so:
<VirtualHost * >
#Basic setup
ServerAdmin [email protected]
ServerName www.mydomain.com
DocumentRoot /var/www/mydomain.com/docs
<Directory /var/www/mydomain.com/docs>
Order Deny,Allow
Allow from all
# Don't show indexes for directories
Options -Indexes
</Directory>
</VirtualHost>
Now, to enable the site you use the a2ensite command (Note:use a2dissite to disable). The following creates a symlink /etc/apache2/sites-enabled/mydomain.com, which enables the site.
$> a2ensite mydomain.com
You need to reload Apache to see the site...
$> /etc/init.d/apache2 reload
If DNS is working, you should now be able to point your browser at www.mydomain.com see the index.html page you created above.