2014-10-30 161 views
1

正如我的用戶名所示,我是一名新手程序員。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以下消息: 「找不到服務器」

任何幫助/指導表示讚賞。

祺....

回答

3

您需要在此修改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

相關問題