Apache在本地主机上工作,但不在服务器名称上

Apache在本地主机上工作,但不在服务器名称上

问题描述:

正如我的用户名所示,我是一名新手程序员。Apache在本地主机上工作,但不在服务器名称上

我试图在Ubuntu简单的Apache服务器的配置,

我已经.conf文件下创建的/etc/apache2/sites-available/awesome.conf与下面的代码。此外,我在/ etc/apache2/sites-enable中创建了一个符号链接,并重新启动了Apache。

<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.myawesome.org 

ServerAdmin [email protected] 
DocumentRoot /var/www/awesome 
DirectoryIndex hello.php 


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

当我访问本地主机/真棒/ hello.php我得到所需的文本“Hello World”。

但是,当我键入www.myawesome.org它dispays以下消息: “找不到服务器”

任何帮助/指导表示赞赏。

祺....

您需要在此修改hosts文件,并添加服务器名指向为localhost

打开主机与文件:

sudo nano /etc/hosts 

...而且这个文件的结尾添加:

127.0.0.1 www.myawesome.org 
+0

非常感谢你是真的明星...... :) 127.0.0.1被本地主机所以我用127.0.0.2。希望这是好的...好东西是有用的:) – NovoiceProgrammer 2014-10-30 16:33:25

+0

我如何使问题的状态为“已解决” – NovoiceProgrammer 2014-10-30 16:39:22

+0

我很感激能够提供帮助。要将问题标记为已解决,您需要点击复选标记。检查这个图像: http://i.stack.imgur.com/uqJeW.png – starless13 2014-10-30 16:41:26