Running WampServer on Windows 8.
Posted by: Nacirema (---.zoominternet.net)
Date: January 02, 2013 08:26PM

Running WampServer on Windows 8!

I am not an expert, but based on hours of searching the internet, this is what I did.

I installed WampServer on a 64 bit Windows 8 Dell Laptop (wampserver2.2e-php5.4.3-httpd-2.4.2-mysql5.5.24-x64) with the local website folders being in C:\wamp\www.

Here are the local sites I have: I have the www site because WampServer installation includes an index.php page in C:\wamp\www. I have a test site, C:\wamp\www\mytest, with an index.html page. I have a project already at c:/__dev/mysite with an index.html page.

So, I had to get browser access not just to "www", but to "mytest" in the www folder, and the "mysite" (which is not in the www folder). For convenience sake, I also made a more direct link to phpMyAdmin using "mydb" as a host name.

Launching an editor (can use Windows' Notepad) with right-click "Run as administrator" I added the following host names to
C:\Windows\System32\Drivers\etc\hosts

127.0.0.1 localhost # or http: //127.0.0.1, or, with WampServer, http: //127.0.0.1:80 (defaults to first entry in httpd-vhosts.conf)
127.0.0.1 www # at C:\wamp; with index.php
127.0.0.1 mydb # at C:\wamp\apps\phpmyadmin3.5.1; with index.php
127.0.0.1 mytest # at C:\www\mytest; with index.html
127.0.0.1 mysite # at C:\__dev\mysite; with index.html

(The “#” is for comments.)

You have to restart the computer after the change to the hosts file (or, depending on the computer, at least log out and then back in again) so that Windows will read the above file. The host names become usable when you add virtual host specifications, and when the WampServer is actually running.

I added virtual hosts to
C:\wamp\bin\apache\apache2.4.2\conf\extra\httpd-vhosts.conf

I used settings found on the internet. Note that "Options Indexes" below just means that if there is no index file then show the folder contents rather than telling me I am forbidden access. It is not needed as long as there is an index file. (Note also that I am on a personal computer that is behind a firewall. In other environments the settings are not appropriate except, maybe, just to see that the virtual hosting actually works.)

# Options Indexes: Allow directory list if no index file. Otherwise, leave out.
# AllowOverride None: Might need to change if using .htaccess directives
# Info on Apache directives are on the Apache Core features page...
# httpd.apache.org/docs/2.2/mod/core.html
#
# Default
<VirtualHost *:80>
ServerName www
DocumentRoot "C:/wamp/www"
DirectoryIndex index.php
<Directory "C:/wamp/www">
Options Indexes
AllowOverride None
Order allow,deny
Allow from All
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName mydb
DocumentRoot "c:/wamp/apps/phpmyadmin3.5.1/"
DirectoryIndex index.php
<Directory "c:/wamp/apps/phpmyadmin3.5.1/">
Options Indexes
AllowOverride None
Order allow,deny
Allow from All
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName mytest
DocumentRoot "C:/wamp/www/mytest"
DirectoryIndex index.html
<Directory "C:/wamp/www/mytest">
Options Indexes
AllowOverride None
Order allow,deny
Allow from All
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName mysite
DocumentRoot "C:/__dev/mysite"
DirectoryIndex index.html
<Directory "C:/__dev/mysite">
Options Indexes
AllowOverride None
Order allow,deny
Allow from All
</Directory>
</VirtualHost>

Make up your own virtual hosts in place of mytest and mysite. You can have fewer or more hosts, but list them in the Windows’ “hosts” file, too, as shown at the beginning of this post. Both VirtualHost specifications are similar. Just change…

- ServerName (host name)
- DocumentRoot (note that there are forward slashes)
- DirectoryIndex (possibilities for index files are shown in httpd.conf file and after installation of WampServer they were index.php, index.php3, index.html, or index.htm)
- Directory (which is the same specification as for the DirectoryRoot).

If you alter httpd-vhosts.conf while WampServer is running you need to stop WampServer and start it again so that it will read the file again.

At this point, if you logged back into Windows after altering the hosts file, and used WampServer to Start All Services after altering the above files, you can browse to www and sites placed as subfolders in the www folder, but not to a host which is not in the www folder. If you try to browse to that type of host, a host that is not in the www folder, such as my “mysite”, you might get a "FORBIDDEN - access denied..." message. Use the WampServer icon in the taskbar and look at Apache error log and you will see something like this...

[Tue Jan 01 21:35:45.620297 2013] [authz_core:error] [pid 6656:tid 860] [client 127.0.0.1:51583] AH01630: client denied by server configuration: C:/__dev/mysite/

Notice that it says "client denied by server configuration".

What I did to resolve that was change the server configuration by changing…
C:\wamp\bin\apache\apache2.4.2\conf\httpd.conf

There is a place where it says something like the following...

# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride None
Require all denied
</Directory>

and I changed the settings to...

<Directory />
AllowOverride None
Require all granted
</Directory>

If you alter httpd-vhosts.conf while WampServer is running you need to stop WampServer and start it again so that it will read the file again.

Now I can browse too all the added host names by entering into the browser location bar www, mydb, mytest, or mysite. Using localhost is the same as using www as long as you are using the same WampServer installation. If you install and start a different server, the meaning of localhost can change depending on the settings for that server. So, when referring to the host sites, as when setting parameters in an sdk, you might want to be specific and use www instead of localhost.

If you browse to a host and have an error, and then edit your configuration files and try to browse to the host again, and if you see an error again, you might also need to do a refresh of the page to make sure the error page wasn’t just coming from the browser’s cache. If your web page is based on a script, like JavaScript, your browser must have that enabled.

If you are new at using an sdk with virtual host, note that you might not have to add the server to the sdk along with start/stop commands and php.exe location, because the WampServer program starts and stops the Apache server and serves up the web pages and executes the PHP. For example, I installed Aptana Studio 3 and loaded the mysite folder as a project by using Import, “Existing Folder as New Project” from C:\__dev\mysite, as Project Type: “Web – Primary”. I then used the menu Run, Run Configurations, clicked the New Launch Configuration icon, named it “mysite”, set “Specific page” to /mysite/index.html, and set “Use base URL” to http: //mysite/ (without the space), and left unchecked “Append project name”. Click Apply and Run. It showed up for me in the browser and since I have links in the index page to PHP programs, one using AJAX to access the MySQL database (I added data already), and the other being the Show_System_Information.php, I brought those pages up and they worked, too. It can now be run at any time within the sdk by clicking the Run dropdown in the button bar and selecting “mysite”. The point being that I did not actually add the server to the Aptana Servers list and yet I can work with the sites files and browse them, and that is pretty nice for now.

I believe that covers every change I made. Mainly I wrote this as a personal log of what I did, but I hope it helps others get up and running.

Options: ReplyQuote


Sorry, only registered users may post in this forum.