Hi all,
I’ve searched, and read tons of how-to articles, and I think I’m just missing something somewhere obvious. But this is driving me batty.
I have a working WP 4.5.3 website which (for now) I’d like to avoid linking too, but I can in some kind of private message or email if necessary. This is a standard vanilla WP install–single installation–but using modified themes and about a dozen plugins, and the like.
Anyway, right now the site is set up in a subdir off of \var\www\, named \wpdirectory. There is an .htaccess and index.php file in var\www (i.e. the web root).
Here’s the contents of .htaccess in the root (\var\www):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
And here’s the contents of index.php in the root (\var\www):
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wpdirectory/wp-blog-header.php' );
In the subdirectory and install locale itself (\var\www\wpdirectory), there’s an .htaccess file that reads:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wpdirectory/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wpdirectory/index.php [L]
</IfModule>
# END WordPress
WordPress itself is set with the following values in the panel\db:
WordPress Address (URL): http://somedomain.com/wpdirectory
Site URL: http://somedomain.com
Now, this all works great! Any incoming requests to http://somedomain.com are routing to the WP install (and site) as needed. Fantastic, right?
BUT, now we want to come in and stand up a new WP install in a different subdirectory. Let’s say it’s at var\www\newsite
And we can’t do that, as it stands, because we’re not using \sites-available\website.conf files of any kind. If you hit this box in any way, including by the server IP, your browser traffic is routed to the somedomain.com WP site. That’s not the end of the world as long as only a single domain is pointed at the site, but you can see the obvious issue if we want to come in with a second production domain pointing to a different subdir\installation.
As part of that, it makes sense to go ahead and create a somedomain.com.conf file in Apache and enable it in sites-enabled, and then do the same thing for the new site. We want everything nice and segregated between the two completely different sites and installs, after all, and in the future we can add more sites this way…
So here’s the kind of .conf file we tried to do for the existing somedomain.com website. After all, it’s a good dry run for the upcoming site anyway.
<VirtualHost *:80>
ServerAdmin support@somedomain.com
ServerName somedomain.com
ServerAlias www.somedomain.com
DocumentRoot /var/www/wpdirectory
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/wpdirectory>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/wpdirectoryerror.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/wpdirectoryaccess.log combined
</VirtualHost>
…And we enable this in apache sites-enabled using the typical console commands, and it appears to work, and then…
We get weird errors on the site. Only the homepage and some of the images and the like appear.
The hosting company’s Linux admins’ suggestion was to go ahead and set up the .conf file, but remove the subdir reference from the .htaccess file in the /wpdirectory subdir itself (we have Apache support, which is good because my kung fu is not strong in Apache). So we wind up with the .htaccess file in the subdir looking like:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This enables us to browse more of the site, but things like images and the like–which are stored in the media library and db with refs like /wpdirectory/wp-content/uploads/blah.jpg–break at this point.
So I’m not sure what to do. I have a staging site, but I’ve been unable to replicate this exact setup there, for a number of reasons (one being that I don’t have a valid domain to point to staging, and even spoofing one in my hosts file and changing the db refs in the staging db to the spoofed domain doesn’t work).
In a perfect world, we can segregate that production domain AND be prepared for the second production and site, which as I said will also be in its own site and subdir. This is a big deal because we have a hard launch date of next week, and if I can’t get this all figured out before then I’m going to have to stand up a new cloud server instance just to run one WP install.
All this indicates, to me, that I’m overlooking something elementary somewhere.
Thanks SO MUCH to anyone who can help. And forgive me if anything seems obvious. As I said, I’m not a LAMP guy. I’m learning what I can as fast as I can.