phpwordpressapachesyntaxvirtual-hosts

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. 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?


Solution

  • You can't use underscore in host name.