Ubutntu下apache安装和配置

阅读更多
1. 安装

sudo apt-get install apache2

2. 配置

安装成功后,在/etc/apache2/目录下的文件和目录如下:
-rw-r--r-- 1 root root 10104 2008-11-05 23:47 apache2.conf
drwxr-xr-x 2 root root  4096 2008-11-26 00:52 conf.d
-rw-r--r-- 1 root root   374 2008-11-26 01:57 envvars
-rw-r--r-- 1 root root     0 2008-11-26 22:05 httpd.conf
drwxr-xr-x 2 root root  4096 2008-11-26 00:52 mods-available
drwxr-xr-x 2 root root  4096 2008-11-26 00:52 mods-enabled
-rw-r--r-- 1 root root   363 2008-11-26 22:28 ports.conf
drwxr-xr-x 2 root root  4096 2008-11-26 22:44 sites-available
drwxr-xr-x 2 root root  4096 2008-11-26 22:44 sites-enabled

先备份/etc/apach2整个目录

apache2.conf是一个总的配置目录,基本不需要修改

1)修改envvars
export APACHE_RUN_USER=dooluu
export APACHE_RUN_GROUP=dooluu

2)修改ports.conf
NameVirtualHost 192.168.0.101:80

这个IP为apache所在服务器ip

3)打开apache2.conf在最下面可以看到这么一行
Include /etc/apache2/sites-enabled/

也就是把/etc/apache2/sites-enabled/路径下的文件都包含进去,进入/etc/apache2/sites-enabled/路径可以看到,一个000-default指向sites-avaiable/default的软连接

现在来修改000-default


        ServerAdmin [email protected]
        ServerName www.newtest.com
        DocumentRoot /home/dooluu/share/newtest
       
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
       


        ErrorLog /var/log/apache2/newtest.log
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog /var/log/apache2/newtest.log combined
    Alias /images/ "/home/dooluu/share/newtest/images/"
   
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Allow from all
   



一个站点就配置好了,在windows的hosts中做一下绑定
192.168.0.101 www.newtest.com

现在来访问:http://www.newtest.com/images/5.gif

再建立一个站点,我们只需要添加一个配置文件即可,在/etc/apache2/下建立一个目录,路径为: /etc/apache2/sites-images
在该路径下建立一个文件,可以直接把/etc/apache2/sites-avaiable/default拷过来
建立一个软连接:sudo ln -s /etc/apache2/sites-images/default /etc/apache2/sites-enabled/001-default

修改后的内容如下:

        ServerAdmin [email protected]
        ServerName www.images.com
        DocumentRoot /home/dooluu/share/www-images
       
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
       


        ErrorLog /var/log/apache2/www-images.log
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog /var/log/apache2/www-images-access.log combined
        Alias /images/ /home/dooluu/share/www-images/images/
       
                Options Indexes MultiViews FollowSymLinks
                AllowOverride None
                Order deny,allow
                Allow from all
       



同样在windows的hosts中做一下绑定
192.168.0.101 www.images.com

http://www.images.com/images/5.gif

这时将会访问 /home/dooluu/share/www-images/images/下的5.gif

你可能感兴趣的:(Apache,Gmail,Windows,Access)