Apache-2.2
為虛擬域名添加程式碼後 Apache 2.2 伺服器停止
我正在 Apache 2.2 本地伺服器上開發一個網站。該網站仍處於開發階段。我想為我的網站獲取一個自定義域名,這樣我就可以以“mysite.local”或其他方式訪問它,而不是“localhost/xyz.php”。在對Google進行了足夠的研究後,我將這些行添加到了 httpd.conf 文件中:
NameVirtualHost 127.0.0.1 <VirtualHost 127.0.0.1> DocumentRoot “C:/Apache/htdocs" ServerName localhost </VirtualHost> <VirtualHost 127.0.0.1> ServerName the-mini-project.com ServerAlias the-mini-project.com DocumentRoot “C:/Apache/htdocs” </VirtualHost>
我還將該行添加
127.0.0.1 the-mini-project.com
到主機文件中。這些行的語法或其他內容有問題嗎?因為在我添加這些行後伺服器停止執行。當我刪除它們時,它恢復了正常。請幫忙。還有其他建議嗎?謝謝。日誌/error.txt
[Fri Aug 30 19:56:12 2013] [notice] Child 6676: Child process is exiting [Fri Aug 30 19:56:12 2013] [notice] Parent: Child process exited successfully. httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.100 for ServerName [Fri Aug 30 19:56:20 2013] [notice] Apache/2.2.25 (Win32) PHP/5.3.27 configured -- resuming normal operations [Fri Aug 30 19:56:20 2013] [notice] Server built: Jul 10 2013 01:52:12 [Fri Aug 30 19:56:20 2013] [notice] Parent: Created child process 3152 httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.100 for ServerName httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.100 for ServerName
只是一個小錯誤。埠號失去。我自己想通了。對於將來的參考,正確的方法是:
NameVirtualHost 127.0.0.1:80
“<“VirtualHost 127.0.0.1:80”>”
DocumentRoot “C:/Apache/htdocs”
ServerName localhost
“<"/VirtualHost”>"
“<“VirtualHost 127.0.0.1:80”>”
ServerName yoursite.anything
ServerAlias yoursite.anything
DocumentRoot “C:/Apache/htdocs”
“<” /VirtualHost">"
80 是預設埠號。
這種配置毫無意義。日誌可能會或可能不會告訴您它有什麼問題,但我想這是您真正想要的:
NameVirtualHost 127.0.0.1 <VirtualHost 127.0.0.1> DocumentRoot "C:/Apache/htdocs" ServerName localhost ServerAlias the-mini-project.com </VirtualHost>