zoukankan      html  css  js  c++  java
  • unbuntu apahce 2 设置 多域名

    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了

  • 相关阅读:
    Mybatis-plus学习笔记(一)
    Mysql基础(四)分组查询及连接查询
    Mysql 基础(三)排序查询及常用函数
    CyclicBarrier 使用详解
    countDownLatch
    pom所有依赖version红色但是不影响运行
    iText5实现Java生成PDF文件完整版
    【Maven】---Nexus私服配置Setting和Pom
    引用、指针、const、define、static、sizeof、左值右值
    事物隔离级别、MVCC以及数据库中常见锁介绍
  • 原文地址:https://www.cnblogs.com/likwo/p/4694998.html
Copyright © 2011-2022 走看看