Wednesday, June 17, 2009

Cài đặt apache2 trên ubuntu

1.Install apache

$ sudo apt-get install apache2

2.Cấu hình apache

-The default Apache settings in the /etc/default/apache2 configuration file relate to local caching, using the mod_disk_cache module

-You can activate the module with the following command:
$ sudo a2enmod disk_cache

-Global settings for the Apache web server are configured by default in the /etc/apache2
/apache2.conf configuration file

3.Examine the First Host

-The first host is configured in the /etc/apache2/sites-enabled/ directory, in the 000-
default configuration file. It’s a virtual host, linked to the file named default, in the /etc/
apache2/sites-available/ directory

For example, suppose that you are serving the domain www.domain.tld and you wish to add the virtual host www.otherdomain.tld, which points at the same IP address.

NameVirtualHost *:80

VirtualHost *:80
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
/VirtualHost

VirtualHost *:80
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
/VirtualHost


4.Configure Virtual Hosts

$ cd /etc/apache2/sites-enabled
$ sudo cp 000-default website1

$ sudo mkdir /var/www/website1
$ sudo mkdir /var/log/apache2/website1

Các tham số khai báo :

ServerName site1.example.org
ServerAlias www.example.org

DocumentRoot /var/www/website1
Replace /dir with the DocumentRoot directory
ErrorLog Set to the dedicated directory for the log file
CustomLog Set to the dedicated directory for the log file

-Create an index.html file in the /var/www/website1 directory

Client gõ vào trình duyệt www.example.org


No comments:

Post a Comment