如何在本地 ubuntu14.04 上使用域名设置服务器?

Posted

技术标签:

【中文标题】如何在本地 ubuntu14.04 上使用域名设置服务器?【英文标题】:How to setup server with Domain name on local ubuntu14.04? 【发布时间】:2016-11-03 18:48:09 【问题描述】:

如何在本地机器上的上设置域名

【问题讨论】:

您好!浏览此链接肯定会对您有所帮助digitalocean.com/community/tutorials/… 【参考方案1】:

步骤: 1.复制sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/yourdomain.conf 2.编辑yourdoamin.conf:sudo gedit /etc/apache2/sites-available/yourdomain.conf 3.配置域名和IP地址:

   <VirtualHost 12.0.0.12: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@yourdoamin.com
    ServerName www.yourdomain.com
    DocumentRoot /var/www/html/yourprojectroot

    # 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>

保存并退出。 4.进入hosts文件编辑:

sudo gedit /etc/hosts
127.0.0.1   localhost
127.0.1.1   pramodkharade-desktop
127.0.0.12 www.yourdomain.com

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

保存并退出。

5.启用 yourdoamin.conf:

sudo a2ensite yourdomain.conf

6。重启apache:

sudo service apache2 重启

    转到浏览器并输入 yourdoamin.com 并按 Enter

【讨论】:

以上是关于如何在本地 ubuntu14.04 上使用域名设置服务器?的主要内容,如果未能解决你的问题,请参考以下文章

如何设置 Ubuntu 14.04 的 SSH 无密码登录

如何设置 Ubuntu 14.04 的 SSH 无密码登录

本地机器上的 Apache 配置 Ubuntu 14.04

Ubuntu #Apache2 Ubuntu 14.04 LTS系统中设置Apache虚拟主机

VMware下安装虚拟机Ubuntu14.04 Server设置桥接方式

Ubuntu14.04配置Apache支持多个站点