写DNS而不是IP?
我正在做一个项目,我想做一些事情,以便能够更轻松地处理我的远程服务器。写DNS而不是IP?
我有一台服务器上安装了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 [email protected]
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
谢谢您提前
应该不需要触摸服务器上的/etc/hosts
。
使这项工作的重要事情是让所有客户知道该名称,该客户想要访问您的应用程序。要做到这一点,你基本上有两种possibiliies:
- 上所有客户端是为了访问你的应用程序添加到所有
/etc/hosts
一个条目(在Windows上,这是C:\Windows\System32\drivers\etc/hosts
)。这样做是不建议 - 在某些DNS服务器中添加一个DNS记录
shopmoriba.datasystems.fr
,该服务器将访问应用程序的所有客户端访问。如果这仅仅是为了内部使用,请在网络上使用一些DNS服务器,也许已经有一台了。如果您想让应用程序公开可用,则无法通过关联的DNS服务器注册官方域名并发布主机名。
虽然你只在你的服务器上运行一个应用程序,这就足够了。一旦你开始添加要在不同的主机名来发布你将不得不增加更多的<VirtualHost>
-sections并添加ServerName
直插像
`ServerName shopmoriba.datasystems.fr`
到各自VirtualHost
构型的其它应用。
我忽略了使用https
这个话题,因为你没有提到你想要使用它,尤其是在托管多个虚拟主机的服务器上,它足够用于单独的主题。
谢谢,我明白这点更好。 – Deadpool
您可以添加条目到/ etc /主机采用以下格式:
172.30.10.XX shopmoriba.datasystems.fr
请记住,这只适用于hosts文件已更改的本地计算机。
它不工作,因为我认为我需要修改000-default.conf太不? – Deadpool
注册名称与您的客户端(!)使用的DNS服务器应该足够了。除非您使用SSL或虚拟主机,否则您的服务器应该不需要知道名称。 –
我将使用更高版本的虚拟主机,因为我需要在同一台服务器上安装2个应用程序。 – Deadpool