写DNS而不是IP?

时间:2016-08-03 12:23:21

标签: apache dns server ip apache2

我正在开展一个项目,我想做一些事情,以便能够更轻松地处理我的远程服务器。

我有一台服务器,我安装了一台API(dolibarr - ERP / CRM软件)。

此服务器使用Ubuntu 14.04和Apache2。

当我想从网络连接到我的软件时,我打开Firefox,例如,我写http://172.30.10.XX,然后我将进入应用程序登录页面。

但我想创建一个DNS和域名,以便更轻松地连接它。

例如:

http://shopmoriba.datasystems.fr代替写入IP地址。

我的问题是:我该怎么做?

我知道我需要修改一些文件: /etc/apache2/sites-available/000-default.conf /etc/hosts ,但我需要写些什么?

我的 /etc/hosts 文件如下所示:

127.0.0.1       localhost
//127.0.1.1     dolibarr
172.30.10.69    shopmoriba.datasystems.fr

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

我的 /etc/apache2/sites-available/000-default.conf 看起来像是:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/          

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

先谢谢你

2 个答案:

答案 0 :(得分:1)

不需要触摸服务器上的/etc/hosts

使这项工作的重要一点是让所有想要访问您的应用程序的客户知道名称。要做到这一点,你基本上有两种可能性:

  1. 所有客户端上为所有/etc/hosts添加条目(在{是C:\Windows\System32\drivers\etc/hosts上),以便访问您的应用程序。这样做是不推荐
  2. 在某些DNS服务器中添加shopmoriba.datasystems.fr的DNS记录,该DNS服务器将被访问该应用程序的所有客户端访问。如果这仅供内部使用,请使用网络上的某个DNS服务器,也许已经存在一个。如果您想公开提供该应用程序,则无法通过关联的DNS服务器注册正式域名和发布主机名。
  3. 虽然您只在服务器上运行一个应用程序,但这已足够。一旦您开始添加要在其他主机名下发布的其他应用程序,您就必须添加更多<VirtualHost> - 部分并添加ServerName - 行,如

    `ServerName shopmoriba.datasystems.fr`
    

    到相应的VirtualHost - 配置。

    我省略了使用https的主题,因为你没有提到你想要使用它,特别是在托管多个虚拟主机的服务器上,它足以用于单独的主题。

答案 1 :(得分:0)

您可以使用以下格式将条目添加到/ etc / hosts:

172.30.10.XX  shopmoriba.datasystems.fr

请记住,这只适用于hosts文件已更改的本地计算机。

相关问题