Jump to content

Fixes for PW Installation on a shared server


Recommended Posts

Dear Ryan and All,

I just installed PW on a shared server, for the first time, for a client, over at LiquidWeb.com.

(I recommend them highly by the way. I've been with them for 8 years, with shared servers,

VPS and dedicated servers, and their tech support is excellent.)

I ran into two glitches, one of which was significant for the install.php file.

1. Although the shared server was quite full featured, for some reason it didn't have mod_env enabled.

(And LW doesn't mess with changes like that once a shared server has been deployed -- unfortunately.)

Therefore, the line in the .htaccess file to set a var to confirm that mod_rewrite was working, broke.

So, I had to comment it out.

  # Set an environment variable so the installer can detect that mod_rewrite is active.
  # SetEnv HTTP_MOD_REWRITE On

Then, because that no longer was in play, I had to comment out the block of code in install.php that looked for that var.

Since I was able to confirm with a tech that mod_rewrite was on, I didn't need the install file to check it. I commented out these lines:

/*
		if(function_exists('apache_get_modules')) {
			if(in_array('mod_rewrite', apache_get_modules())) $this->ok("Found Apache module: mod_rewrite");
				else $this->err("Apache mod_rewrite does not appear to be installed and is required by ProcessWire.");
		} else {
			// apache_get_modules doesn't work on a cgi installation.
			// check for environment var set in htaccess file, as submitted by jmarjie.
			$mod_rewrite = getenv('HTTP_MOD_REWRITE') == 'On' ? true : false;
			if($mod_rewrite) {
				$this->ok("Found Apache module (cgi): mod_rewrite");
			} else {
				$this->err("Unable to determine if Apache mod_rewrite (required by ProcessWire) is installed. On some servers, we may not be able to detect it until your .htaccess file is place. Please click the 'check again' button at the bottom of this screen, if you haven't already.");
			}
		}
*/

After that, the install worked.

I recommend that a config flag be added somewhere, to allow the install.php file to run without checking for mod_rewrite, with the noted caveat that it would mean that the person installing it must check manually.

2. The second glitch was related to the fact that it was a shared server, and I added some Basic Auth code at the end of the .htaccess file to block the public while the site was being developed. When I did that, the server behaved the way I've seen .htaccess auth break in subdirectories. I'm not sure why it broke in the web doc root, but the solution was the same.

(This has not happened in VPS's, so perhaps it's a symptom with shared servers.)

The symptom, by the way, was that the Basic Auth directives were ignored, and the home page went to a 404 page.

So, after adding this line at the top of the .htaccess file, it all worked.

ErrorDocument 401 "Unauthorized"

This line also worked, but I chose the the first option:

# this was an alternate method to fix the above
RewriteCond $1 !^(401.shtml)

The second option was offered by a brainy LiquidWeb tech, which jogged my memory about the first option.

Even though the second problem wasn't a specific PW issue, I thought it might be a valuable tip for anyone wanting to install PW on a shared server, when the home page has to be protected by Basic Auth. It threw me when I couldn't log into my admin url after installing PW.

Anyway, after all this, PW seems to be behaving quite well on a shared account on LiquidWeb, which is a big step up from Drupal, which, as far as I know, doesn't work well at all in a shared environment.

Plus One for PW. :-)

Edit: I also recommend that you place in the list of server requirements a note about Mod_Env as it relates to SetEnv. It's not only an issue for the installation, but also provides an extra security method for using Basic Auth on the admin login page, as I wrote about in my post here:

http://processwire.com/talk/topic/3706-how-to-blockredirect-one-user-role-away-from-admin-pages/?p=46421

If I had known about this (or thought about it) before deploying the shared account, I would have specified that it was a requirement.

Peter

  • Like 1
Link to comment
Share on other sites

Ryan, maybe curl, file_get_contents (using a full http:// url), or exec/wget can be used to fetch a test page. If the page returns a 404 status, mod-rewrite is off. Of course there's still a chance that one or none of these methods work, but you could try all including the env var and probably prevent a few folks from running into this problem. I'm happy to help, let me know if you want me to take a crack at this.

  • Like 1
Link to comment
Share on other sites

Hello guys, I have http://myurl.com with a pw installation ant it works perfectly.

My question is how do I have to set .htaccess to allow http://myurl.com/anotherweb to load another web with some .html and .js without pw interfering on it?

Probably an easy question for the ones that know how to set up .htaccess.

SOLUTION:

I found a way  http://myurl.com/site/templates/anotherweb

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...