Skip navigation

Is it possible to set up WordPress in a subdirectory?

697 Views 7 Replies Latest reply: Mar 22, 2013 11:10 AM by MrHoffman RSS
chuckbutler Calculating status...
Currently Being Moderated
Mar 17, 2013 5:02 PM

Hi; here's the story:

 

I'm virtual-hosting 3 websites (including mail and ftp) on our in-house MacMini SL server. These sites are pretty basic, and each resides in its own folder on the secondary (non-system) drive inside our MacMini:

 

/Volumes/harddrive2/websites/domain1

/Volumes/harddrive2/websites/domain2

etc.

 

This setup has worked well for several years. But now we want to upgrade our main site ("domain1"), and have begun working with a web design company. This company has told us that we need to have WordPress installed in order to accomplish some of the functionality we have asked for. They also requested that we set up a subdirectory within our main "domain1" directory where they can build and test the new site; then, once it's ready to go live, we would move the new site up one level, replacing the files that are currently in the "domain1" directory. So the folder structure they're asking for looks like this:

 

/Volumes/harddrive/websites/domain1/testing

 

I downloaded MAMP and WordPress (I realize now that MAMP was not strictly necessary, but as I'm not an IT pro it seemed like a fairly user-friendly solution), and indeed, I was able to install all of the necessary files, create a database using phpMyAdmin, install Wordpress, and create a WP admin account. The problem is that I have not been able install WP such that it resides in the /testing subdirectory. There are a couple of issues that may be relevant here:

 

1. MAMP defaults Apache to port 8888. If I don't change that assignment, the consequence is that I have to include :8888 after the domain in order to interact with WP. (I can change the port to 80, but this then interrupts all traffic to my existing websites.) I'm not sure if using :8888 for Apache may somehow be inhibiting my ability to target WP to the /testing subdirectory.

 

2. Interestingly, if I place all the WP files in the /testing subdirectory (which is where I want them), I am able to complete the WP setup (and this works whether Apache is using port 8888 or 80). But the strange thing here is that after WP is up and running it still sees the "domain1" directory, rather than the /testing subdirectory, as the path to WP. IOW, when I look in Settings > General in WP after the WP set up is complete, it shows www.domain1.com as the path to WP, and not www.domain1.com/testing, and any attempt to access WP with a URL that includes the /testing subdirectory fails. No matter what I do, I can only access WP using the main domain directory (www.domain1.com/wp-login.php).

 

When I asked this question on the WP forums, I was advised that this is a server configuration issue that I should pursue with Apple. Put simply: WP needs to reside in the /testing subdirectory while we work on the new site, and then everything in that subdirectly needs to move up one level to the domain1 directory and function there when we're ready to launch. If anyone can suggest a configuration that will make that possible, I would appreciate it; or, if there is some other approach that will accomplish the same end, I'm all ears. Thanks so much.

  • MrHoffman Level 6 Level 6 (11,720 points)

    I'd set up a DNS translation for a testing domain or I would use an existing DNS domain on a variant port, would park the files in a top-level directory (eg: /Volumes/harddrive2/websites/domainWPv2), and conifigure Server Admin to use the domain name, variant port and directory.

     

    I do this with Drupal quite regularly.

     

    I prefer to avoid getting the path involved in the URL, and also not encoding the domain name into the Wordpress files for the site.

     

    MAMP is not something I'd particularly expose to the wild 'net; it's intended for web development and not AFAIK locked down against attacks.  If you use it, you'll need to keep it from getting tangled with the embedded version of Apache.  This tangling is part of why you have to specify the :8888 port, too.  There's no need for MAMP here, either.

     

    FWIW when moving to a CMS, you'll want to be on the security notification mailing list(s) for the package, and you'll need to plan for deploying quick updates — security problems in Wordpress or Drupal or other common CMS packages can be exercised very quickly after they become known, and sometimes the vulnerabilities are exercised before they become known or patched.  This means backups, and related steps to ensure security and recovery after breaches.

  • MrHoffman Level 6 Level 6 (11,720 points)

    On OS X 10.6, complex configurations involving Apache are usually best managed from Server Admin.app, which is part of Server Tools package.  Those tools are installed on 10.6 server, and can be installed on OS X 10.6 client.  That's also common way how your current stuff could have been set up, and that's where you can replicating with the new virtual host

     

    If it's useful, here's a more detailed write-up on Apache virtual hosting and here is the OS X Server 10.6 web services technoiogy manual.  The former is how I generally approach Apache virtual hosting with OS X Server, and the latter is an introduction to how this stuff fits together.  Unfortunately, I'm not sure there's a plain-English version around; as indicated in that article, I use the server tools and the command line for this.

  • MrHoffman Level 6 Level 6 (11,720 points)

    With Server Admin, you'd switch the "old" virtual host entries for the port and the domain name over to the new directory, and you should be good to go.  You'll want to test the web site after that switch-over, of course, on the off chance that the testing virtual host's details got embedded in a configuration file or into the HTML of the web site somewhere.  If the web folks have been following typical web design practices, the whole site is relative to the domain, and the domain itself is not encoded in the HTML.

     

    As for what you didn't ask...

     

    I did not, do not and would not recommand using MAMP here.

     

    MAMP adds complexity to an OS X Server configuration, and adds the potential for vulnerabilities, and you already have a new maintenance project and security risk you're managing with a content management system. 

     

    When last I checked, the MAMP folks specifically recommended against using it in production and against exposing the package to the wilds of the Internet.  It was intended for development and testing.

     

    To be clear: I don't have anything against MAMP for web development use on OS X client and do occasionally use it for that purpose, but I can think of no reason to use it in an OS X Server configuration.

     

    For this case, I would recommend using the existing OS X Server 10.6 Server Admin.app tool to add a virtual host on a variant port.

     

    As a maintenance and security matter separate from the use of MAMP or the integrated Apache server present in OS X Server, Wordpress, Drupal and various other content management system packages are unfortunately common targets for attackers.   From direct experience dealing with the resulting messes from successful breaches at various sites, uncomplicated web site defacements and the SEO-placement hacks are about the least nasty problems that arise.  If the attackers delete stuff, or start generating spam, or swipe sensitive data, things get ugly.

     

    And to be clear on CMS packages: I don't mean to scare you off Wordpress, Drupal or another CMS either.  I use and depend on CMS packages.  This is simply to underscore the need to monitor the CMS security notification lists for new attacks, and to expect to need to keep your Wordpress patches and updates current, to keep your OS X Server backups and web database backup exports current and tested, and to actively monitor your servers.  Your web folks may or will be providing you with a mysqldump database export for backups, or an analogous export for whatever database you're using.

  • MrHoffman Level 6 Level 6 (11,720 points)

    I don't know of and don't find a particularly good discussion of this, and Wordpress has seemingly lacked documentation on OS X Server hosting for a while.

     

    Here is a discussion of setting up Wordpress on OS X Server and the cited article (and do read the comments).

    and also (particularly if you're running something newer than 10.6) this Wordpress discussion and this discussion.

     

    If you're in a hurry, check MacHighway for hosting.  I contract with MacHighway for some of this stuff for a few sites and other services, and they can host these CMS installs for you.  (Took about twenty minutes to get a baseline CMS working over there last weekend.  Installing variant themes can be much more interesting — command-level work appears required — but that's feasible.)  There are other places that host CMS packages, too.  Why do I mention this hosting?  Because if you need this stuff "now" as you mention, hosting gets you going, and you can migrate the site later; as you get more time.

     

    I'd also check with the web folks you're working with, too.   They seem unable or unwilling to provide you with the assistance you're seeking, and to help research the topic for you.   Hosting and managing a CMS is more than just Wordpress or Drupal or whatever, it involves database backups, networking, and some other details.

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.