简体   繁体   English

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

[英]Error when setting up VirtualHost in Wamp - The ServerName has syntax error in file 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.我正在尝试将实时 wordpress 网站移动到我计算机上的本地站点,以便我可以进行更改并进行尝试,而不会弄乱实时站点。 I am using WAMP on a Win7 PC.我在 Win7 PC 上使用 WAMP。

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.我完成了所有步骤......安装了 WAMP 并下载了我的 Wordpress 文件和我的数据库文件,将 wordpress 文件放在 D:/wamp/www/site-name 文件夹中,我在 phpadmin 中创建了一个同名的新数据库作为我下载的数据库,并导入我的数据库,然后我使用 sql 查询将数据库内的 URLS 从http://www.site-name.org更新为 localhost/site-name,然后我更新了数据库名称、用户名和wp-config.pho 文件中的密码以反映 localhost 与实时站点上使用的内容,然后因为我使用的是 apache 2.4.x,我去为我的 wordpress 站点创建一个虚拟主机,因为 localhost 选项被抑制在 httpd.config 文件中……从我收集的内容来看,较新的版本是使用虚拟主机的,所以我试图这样做,而不是取消抑制 localhost 选项。

So, I went to the the c/windows.system32/drivers/etc/hosts file and added the following所以,我去了 c/windows.system32/drivers/etc/hosts 文件并添加了以下内容

# 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: (注意我已经检查了 httpd.config 文件,并且这一行已经处于活动状态:

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

Then, I went to the httpd-vhost.conf file and added in my new virtual host:然后,我转到 httpd-vhost.conf 文件并添加到我的新虚拟主机中:

# 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.但是,在保存并重新启动 WAMP 服务后,我继续在虚拟主机下收到 Site_name 的错误,即:ServerName site_name 在文件 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.我在 httpd-vhosts.conf 中查看了 site_name 服务器的上述代码,但找不到任何语法错误。 The localhost virtual host works, and from what I can tell, the syntax for the site_name server is the same. localhost 虚拟主机可以工作,据我所知,site_name 服务器的语法是相同的。

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.我尝试在 apache 文件夹中运行 httpd.exe 以查看它是否会为我提供有关语法错误的更多详细信息,但是双击它时我无法运行它,而且我不确定如何从中运行它cmd 提示...我试过了,但我一直收到某种套接字错误。

Thank you for the help.感谢您的帮助。

Can someone please help be figure out what might be happening.有人可以帮助弄清楚可能会发生什么。 What am I missing something?我错过了什么?

您不能在主机名中使用下划线。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法执行菜单项(内部错误)...尝试访问httpd.conf和httpd-vhosts.conf时找不到文件 - Could not execute menu item (internal error) … cannot find file when attempting to access httpd.conf and httpd-vhosts.conf httpd.conf VS httpd-vhosts.conf - httpd.conf VS httpd-vhosts.conf 无法使用httpd-vhosts.conf从子域重定向到子子域 - Cannot redirect to sub-subdomain from subdomain using httpd-vhosts.conf httpd.conf 中可能存在语法错误 - There may be a syntax error in httpd.conf WAMP无法启动:获取“ AH00526:C:/wamp/bin/apache/Apache2.4.4/conf/httpd.conf的第224行的语法错误” - WAMP won't start: Getting “AH00526: Syntax error on line 224 of C:/wamp/bin/apache/Apache2.4.4/conf/httpd.conf” Apache 2.4.4 WAMP VHosts错误 - Apache 2.4.4 WAMP VHosts error 在El Capitan上安装PHP 5.6:httpd.conf的语法错误 - Installing PHP 5.6 on El Capitan: Syntax error with httpd.conf httpd:如何了解httpd.conf中的错误在哪里 - httpd: how can I understand where the error in httpd.conf is (Apache:无法加载模块)httpd:C:/Apache24/conf/httpd.conf:Cannot load C:/php/php7apache2_4.Z0619AFZ31224AB5248C 的第 539 行出现语法错误 - (Apache : couldn't load module) httpd: Syntax error on line 539 of C:/Apache24/conf/httpd.conf:Cannot load C:/php/php7apache2_4.dll into server: Wamp服务器:更改Apache的httpd.conf吗? - Wamp server: Changing httpd.conf for apache?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM