doufei3152 2017-02-03 21:26
浏览 238
已采纳

在Wamp中设置VirtualHost时出错 - ServerName在文件httpd-vhosts.conf中存在语法错误

I am trying to move a live wordpress website to a local site on my computer so that I can make changes and try things out without messing up the live site. I am using WAMP on a Win7 PC.

I went through all the steps...installed WAMP and downloaded my Wordpress files and my database file, put the wordpress files in the D:/wamp/www/site-name folder, I created a new database in phpadmin with the same name as my downloaded datebase, and imported my database, then I updated the URLS inside the database from http://www.site-name.org to localhost/site-name using the sql queries, then I updated the database name, username and password in the wp-config.pho file to reflect what is being used on the localhost versus the live site, then because I was using apache 2.4.x, I went to create a virtual host for my wordpress site because the localhost option was suppressed in the httpd.config file...and from what I gathered, the newer version is made to use virtual host, so I was attempting to do that, instead of unsupressing the localhost option.

So, I went to the the c/windows.system32/drivers/etc/hosts file and added the following

# localhost name resolution is handled within DNS itself.
    127.0.0.1       localhost
    ::1             localhost

# site-name name resolution
    127.0.0.1   site_name                   #local version of website
    ::1         site_name

( note I had already checked the httpd.config file, and this line was already active:

# Virtual hosts
 Include conf/extra/httpd-vhosts.conf

Then, I went to the httpd-vhost.conf file and added in my new virtual host:

# Virtual Hosts
#

<VirtualHost *:80>
    ServerName localhost
    ServerAlias localhost
    DocumentRoot D:/wamp/www
    <Directory  "D:/wamp/www/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>
#
#
<VirtualHost *:80>
    ServerName site_name
    ServerAlias site_name
    DocumentRoot D:/wamp/www/site_name
    <Directory  "D:/wamp/www/site_name">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

However, after saving that, and restarting WAMP services, I continue to get an error for Site_name under Virtual host, that says: The ServerName site_name has syntax error in file D:/wamp/bin/apache/apache2.4.23/conf/extra/httpd-vhosts.conf.

I have looked over the above code in the httpd-vhosts.conf for the site_name server, but can't find any syntax errors. The localhost virtual host works, and from what I can tell, the syntax for the site_name server is the same.

I tried running httpd.exe in the apache folder to see if it would give me more details on the syntax error, but I can't get it to run when double clicking on it, and I wasn't sure how to run it from the cmd prompt...I tried, but I kept getting some kind of socket error.

Thank you for the help.

Can someone please help be figure out what might be happening. What am I missing something?

  • 写回答

1条回答 默认 最新

  • drl971115 2017-02-03 21:31
    关注

    You can't use underscore in host name.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

    报告相同问题?

    悬赏问题

    • ¥15 spyder运行重复
    • ¥15 我考考你,这代码是对的还是错的?
    • ¥15 我用C语言easyx图形库绘制了一个3d游戏方框透视,但进入游戏时候鼠标准星对准方框边缘 鼠标光标就会弹出来这是啥情况怎样让光标对准绘制的方框点击鼠标不弹出光标好烦这样
    • ¥20 用Power Query整合的问题
    • ¥20 基于python进行多背包问题的多值编码
    • ¥15 相同型号电脑与配置,发现主板有一台貌似缺少了好多元器件似的,会影响稳定性和使用寿命吗?
    • ¥15 C语言:数据子序列基础版
    • ¥20 powerbulider 导入excel文件,显示不完整
    • ¥15 paddle训练自己的数据loss降不下去
    • ¥20 用matlab的pdetool解决以下三个问题