码迷,mamicode.com
首页 > 其他好文 > 详细

unbuntu apahce 2 设置 多域名

时间:2015-08-02 06:19:09      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:

1.找到apache2 的设置路径

默认的apache的路径为/etc/apache2/

 

2. 修改httpd.conf

本文192.168.0.1 为自己的服务器的ip,下面一样的意思

ServerName 192,168.0.1:80
NameVirtualHost 192,168.0.1.166

 

3. 修改 /etc/apache2/sites-available/default文件 此文件为第一个网站的域名绑定信息

<VirtualHost 192.168.0.1>
    Servername qq.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        #AllowOverride None
        AllowOverride ALL 
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        #AllowOverride None
        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-available/test

<VirtualHost 192.168.0.1>
    Servername appask.cn
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/testaaaaa
	<Directory />
		Options FollowSymLinks
		#AllowOverride None
		AllowOverride ALL 
	</Directory>
	<Directory /var/www/app>
		Options Indexes FollowSymLinks MultiViews
		#AllowOverride None
		AllowOverride ALL 
		Order allow,deny
		allow from all
	</Directory>
	
	ErrorLog ${APACHE_LOG_DIR}/error_app.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog ${APACHE_LOG_DIR}/access_app.log combined

</VirtualHost>

  

5. 执行 sudo a2ensite test 在sites-enable可以看到多了一个指向test的软链接

 

6.重启apache2 : service apache2 restart

 

一切就Ok了

 

unbuntu apahce 2 设置 多域名

标签:

原文地址:http://www.cnblogs.com/likwo/p/4694998.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!