zoukankan      html  css  js  c++  java
  • 阿里云腾讯云服务器ubuntu多域名配置

    1、将域名A记录解析到服务器的公网 IP 地址,把www也添加A记录到公网ip

    2、ubuntu系统修改hosts文件,hosts文件目录为/etc/hosts,可以用vim编辑  sudo vim /etc/hosts
    添加内容:

    127.0.0.1   a.com  www.a.com

    127.0.0.1    b.com  www.b.com

    编辑后,你需要重新启动一下你的网络。命令:/etc/init.d/networking restart

    3、创建站点目录,比如/data/www/a     和/data/www/b   ;分别在a文件夹下和b文件夹下新建index.html文件,内容自己随便写。

    4、进入目录 /etc/apache2/sites-available/ ;可以看到有一个默认文件000-default.conf,修改内容如下:

    <VirtualHost *:80>  
            ServerName a.com 
            ServerAlias www.a.com  
            <Directory /data/www/a> 
                #AllowOverride伪静态 
                AllowOverride All
                Require all granted  
            </Directory>  
            ServerAdmin webmaster@localhost  
            DocumentRoot /data/www/a
            ErrorLog ${APACHE_LOG_DIR}/error.log  
            CustomLog ${APACHE_LOG_DIR}/access.log combined  
    </VirtualHost>

    复制000-default.conf文件并命名为001-default.conf作为站点b的配置文件,相应修改域名和网站根目录

    5、启动站点

    sudo a2ensite 000-default.conf

    sudo a2ensite 001-default.conf

    如果提示需要运行apache load,你可以按照提示运行命令。

    6、重启Apache service

    sudo service apache2 restart

    7、成功


    中途遇到的问题:apache无法启动

    1、提示:Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.

    解决方法:命令:apache2ctl configtest;可以查看出现错误文件行号,主要是000-default.conf出现错误,注意空格

    2、提示:Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

    解决方法:hosts文件配置错误,查看是否添加了域名指向127.0.0.1

  • 相关阅读:
    Python语言简介以及特点
    计算机组成原理简述
    Python中的dict字典的用法
    Python3中IO文件操作的常见用法
    Python中的装饰器的使用及固定模式
    Python中的解决中文字符编码的问题
    Python中常见字符串去除空格的方法总结
    Python中print函数中中逗号和加号的区别
    当引用了Properties.Settings后,如果执行的时候,出现"配置系统无法初始化" 或者 某某节点不正确
    修改IP的方法(C#)
  • 原文地址:https://www.cnblogs.com/idjl/p/9610581.html
Copyright © 2011-2022 走看看