VirtualHost issue with Wordpress in subdirectory

Problems with the Windows version of XAMPP, questions, comments, and anything related.

VirtualHost issue with Wordpress in subdirectory

Postby realistdreamer » 11. August 2011 21:53

Sorry in advance for the long post.

Goal:
Local Development of Wordpress 3.0 with:

1. Easy subversion updating of core Wordpress files, themes and plugins
2. Using mysite.com instead of localhost for easier deployment

I had number 2 working using the advice from http://devpress.com/blog/a-really-sweet ... vironment/ and the httpd.conf and hosts file changes listed below. Then, I moved core Wordpress files into a subdirectory based on the directory structure below and item 1 worked, but item 2 is now broken. See http://ottopress.com/2011/creating-a-wo ... using-svn/ re: item 1. I’m sure it has something to do with the Virtual Host setup I have, but I don’t know how to fix it.

Environment:
Windows XP
XAMPP 1.7.4
Wordpress 3.2.1

Directory Structure:
In my xampp folder, I have
/htdocs/mysite/
Under this directory, I have:
/wp_core (all wordpress files from svn with my modified .htaccess)
/wp_content (exported from /wp_core with my added plugins/themes)
wpconfig.php

.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mysite/wp_core/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mysite/wp_core/index.php [L]
</IfModule>
# END WordPress

httpd.conf
<VirtualHost 127.0.0.1>
ServerName mysite.com
DocumentRoot "C:/xampp/htdocs/mysite/wp_core"
ServerAdmin me@mysite.com
<Directory C:/xampp/htdocs/mysite/wp_core>
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>

wp-config.php

/* Added definitions to move content location to subfolder */
define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/mysite/wp_content’ );
define( 'WP_CONTENT_URL', 'http://localhost/mysite/wp_content’);

Hosts file
127.0.0.1 localhost
127.0.0.1 mysite.com #local
# 123.4.5.6 example.com #production


Results I’m getting:
With the setup above, I get a blank screen at mysite.com. I assume this is because for some reason it’s pointing to /htdocs/mysite where there is now no index.php.

If I remove the Virtual Host code from the httpd.conf file, I get XAMPP setup by going to mysite.com which I assume is pointing to xampp/htdocs which has index.php for XAMPP. I can get to my Wordpress site either by using mysite/wp_core or localhost/mysite/wp_core, but I can’t seem to get Virtual Host to resolve to mysite.com and see the site.
realistdreamer
 
Posts: 8
Joined: 11. August 2011 21:48

Re: VirtualHost issue with Wordpress in subdirectory

Postby Sharley » 12. August 2011 00:13

The correct and expected location for vhosts settings is in C:\xampp\apache\conf\extra\httpd-vhosts.conf file.

Always remember to create backup copies of any configuration file before editing so you have a known working replacement should your edits go pear shaped.

Please return your httpd.conf file back to the default settings and then try these httpd-vhost.conf file settings - you may copy and paste if you prefer:
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>

<VirtualHost *.80>
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot "C:/xampp/htdocs/mysite/wp_core"
ServerAdmin me@mysite.com
<Directory "C:/xampp/htdocs/mysite/wp_core" >
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
CustomLog logs/mysite_access.log combined
ErrorLog logs/mysite_error.log
LogLevel debug
</VirtualHost>
Save the file and restart Apache.

If Apache fails to start then read the C:\xampp\apache\logs\error.log file for clues.
If you have issues with mysite.com then they will now have their own log files in the main Apache logs folder.

Your Windows hosts file seems in order.

http://mysite.com
and
http://www.mysite.com
should both now work and present the index file contained in your vhost DocumentRoot, also
http://localhost
should present the XAMPP Welcome page after redirecting to
http://localhost/xampp
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: VirtualHost issue with Wordpress in subdirectory

Postby realistdreamer » 12. August 2011 00:44

I think vhost file is being ignored. I put in the code and it had NO effect. Yes, I shut down/exited the control panel for XAMPP. Yes, I emptied the cache in chrome and restarted the browser.

Essentially, I get mysite.com turning into mysite.com/xampp with the modifications provided or without. I also get to the right place if I manually type in mysite.com/mysite/wp_core.

It's like it's not reading the vhost at all. When I put the information in httpd.conf it broke so I assume it was reading the information in there. Is there something I need to put in another file so vhosts get read?
realistdreamer
 
Posts: 8
Joined: 11. August 2011 21:48

Re: VirtualHost issue with Wordpress in subdirectory

Postby realistdreamer » 12. August 2011 00:48

This site suggests reversing the slashes.
http://sawmac.com/xampp/virtualhosts/
realistdreamer
 
Posts: 8
Joined: 11. August 2011 21:48

Re: VirtualHost issue with Wordpress in subdirectory

Postby Sharley » 12. August 2011 00:53

Did you read the error logs?

Make sure that this section, down near the bottom of your httpd.conf, file looks like this:
Code: Select all
# Virtual hosts
Include "conf/extra/httpd-vhosts.conf"


realistdreamer wrote:This site suggests reversing the slashes...
If you look in all XAMPP configuration files you will see the correct direction for all the slashes, but by all means reverse them as long as they are contained with quotation marks - but that is not the issue if your vhosts file is not being read in the first place - see the error log files.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: VirtualHost issue with Wordpress in subdirectory

Postby realistdreamer » 12. August 2011 01:16

Thanks for the help. The error log shows:

[Thu Aug 11 16:33:22 2011] [debug] proxy_util.c(1803): proxy: worker ajp://127.0.0.1:8009/examples already initialized
[Thu Aug 11 16:57:30 2011] [debug] proxy_util.c(1803): proxy: worker ajp://127.0.0.1:8009/examples already initialized
[Thu Aug 11 17:01:48 2011] [debug] proxy_util.c(1803): proxy: worker ajp://127.0.0.1:8009/examples already initialized

The line in httpd.conf is correct

I now think it's doing something because when I manually type in mysite.com/mysite/wp_core Wordpress comes up, but where the post text is supposed to be it shows: http://localhost/mysite/wp_core/mysite/wp_core/

I also tried adding the lines indicated in another thread, which didn't help, but I'm not sure if that was responsible for the log errors. viewtopic.php?f=16&t=39224&view=next#p150289
realistdreamer
 
Posts: 8
Joined: 11. August 2011 21:48

Re: VirtualHost issue with Wordpress in subdirectory

Postby Sharley » 12. August 2011 01:23

You are typing the wrong URI in your browser.

I did post the correct URIs in my first post
Sharley wrote:http://mysite.com
and
http://www.mysite.com
should both now work and present the index file contained in your vhost DocumentRoot, also
http://localhost
should present the XAMPP Welcome page after redirecting to
http://localhost/xampp


realistdreamer wrote:I now think it's doing something because when I manually type in mysite.com/mysite/wp_core Wordpress comes up, but where the post text is supposed to be it shows: http://localhost/mysite/wp_core/mysite/wp_core/
This is clearly wrong, you do not need to specify any folder locations as the URIs I posted will do the job for you.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: VirtualHost issue with Wordpress in subdirectory

Postby realistdreamer » 12. August 2011 01:32

First, I really appreciate the help.

I am typing exactly "http://mysite.com". When I do this, it redirects to "mysite.com/xampp". This is telling me vhost is not working and I have NO idea what the error logs mean.

The other URI I typed is clearly not what I want to type to get to Wordpress, but it was what was actually getting me to the Wordpress install. It showed the theme, but with a 404 error, indicating http://localhost/mysite/wp_core/mysite/wp_core/ was not found. It confirms that mysite.com is resolving to localhost, not localhost/mysite/wp_core as I'd like.
realistdreamer
 
Posts: 8
Joined: 11. August 2011 21:48

Re: VirtualHost issue with Wordpress in subdirectory

Postby Sharley » 12. August 2011 01:55

I am here to help where I can but it can be difficult sometimes when I can't see what you see or know what else you are doing that I don't know about... :)
...but we will try and get you moving forward if we can as your original issue of incorrect vhost config is not unique and should have been corrected by my first post.

The correct URI is the one I posted for the vhost configuration I also posted.

If you don't get the expected result then we have to look for and correct the reason.

Try http://mysite.com/index.php - if you have an index.php file in the DocumentRoot wp_core folder, change it to what ever index file is in that folder.

Also in the htdocs folder rename the index.php and index.html files to index_orig.php and index_orig.html.

Now if you want the XAMPP Welcome page you would type the full URI:
http://localhost/xampp/index.php


Please paste in between forum code tags your current httpd-vhosts.conf file.

Also, try rebooting as sometimes this helps with strange results caused by some XP system issues.

The configuration I posted should work without issue if you have an index file in the DocumentRoot of your vhost.

Check your hosts file and also paste the contents in between code tags up to the entry for mysite.com if it is a huge file.

The host file entries for 127.0.0.1 localhost and 127.0.0.1 mysite.com should be the first entries in the file.

Make sure when you saved the file after editing it in a text editor it did not add any file extension.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: VirtualHost issue with Wordpress in subdirectory

Postby realistdreamer » 12. August 2011 02:13

Have to run out for 4 hours. Will try your latest suggestion as soon as I return. Thanks again.
realistdreamer
 
Posts: 8
Joined: 11. August 2011 21:48

Re: VirtualHost issue with Wordpress in subdirectory

Postby Sharley » 12. August 2011 02:34

If it's any consolation, I have just recreated your exact setup, minus WP, using my vhost and host file settings in a fresh install of 1.7.4 and they all work perfectly.

The .htaccess file in your DocumentRoot may well be the problem with this localhost redirection to xampp, as it will override any configuration file settings in the Apache server.


So as a test for an errant .htaccess file, try and drag (move) the .htaccess file onto your desktop (easier sometimes than renaming it as Windows has a headache with .ht* file names)

Now try http://mysite.com/ again - this is only for testing to see if the .htaccess file is influencing this strange issue but if you have the same result then drag it back into wp_core again.

If the URI finally works minus the .htaccess file then you know that the .htaccess file needs to be recreated by WP using the correct paths - I am not a WP freak so you may need someone who is, to help with WP .htaccess file issues.

In the .htaccess code you posted I did notice an issue that your rewrite base and path should now be just your DocumentRoot of the vhost namely wp_core not /mysite/wp_core and this may well be the problem that would need correcting if you return the .htaccess to it's original location or you could try this correction before moving it out for testing.
.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mysite/wp_core/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mysite/wp_core/index.php [L]
</IfModule>
# END WordPress
Try editing the .htaccess file or perhaps you need to also change some settings in the WP configuration to reflect your servers DocumentRoot of wp_core as it does not now contain the folder mysite.
Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp_core/index.php [L]
</IfModule>
Hopefully this edit may do the trick to get you moving in the right direction. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: VirtualHost issue with Wordpress in subdirectory

Postby realistdreamer » 12. August 2011 09:00

WOW. Human Error Sucks. :oops:

I had
Code: Select all
<VirtualHost *.80>
instead of
Code: Select all
<VirtualHost *:80>
. Turns out it matters whether it's a "." or a ":" :roll:

Unfortunately, that did not solve the entire Wordpress problem which is a bit circular.

First, in setting up WP initially without the Virtual Host, I had the blog settings site url set to http://localhost/mysite/wp_core. Once I got the Vhost working I needed to use PHPMyAdmin to fix that problem because I couldn't get back in to the admin interface to do it through WP and it's kept in the db.

Second, I still had the problem of getting to the content directory which is now at the same level as the wp_core directory. Initially, it looked like
Code: Select all
define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/mysite/wp_content' );
which had to change to
Code: Select all
define( 'WP_CONTENT_DIR', 'C:/xampp/htdocs/mysite/wp_content' );


Now all seems to be working well. After I add multisite capability to this setup, I will have the tutorial of all tutorials.

Thanks so much for the help and I hope this helps someone else.
realistdreamer
 
Posts: 8
Joined: 11. August 2011 21:48

Re: VirtualHost issue with Wordpress in subdirectory

Postby realistdreamer » 12. August 2011 09:06

After getting all that done, need to redo the .htaccess file by changing permalinks again. Cleans it up like suggested.
realistdreamer
 
Posts: 8
Joined: 11. August 2011 21:48


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 44 guests