• 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了

  • 相关阅读:
    过滤器解决乱码问题
    读取配置文件javase
    Django
    python之路
    最火的前端框架--Vue
    web前端
    MySQL笔记
    python 从想学到坚持
    python 坚持下来会更好
    简单的装系统大佬别喷谢谢拉 欢迎指出不足指出
  • 原文地址:https://www.cnblogs.com/likwo/p/4694998.html
Copyright © 2020-2023  润新知