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

在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 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型