Problems Installing MODx Revolution with suPHP & default File Permission Settings

Coming from a Windows background, one of the first differences I stumbled across while learning to administrate a Linux server .. was the concept of permissions, which includes the topic of file & directory ownership.

Permissions is not a very romantic subject, so I won't bore you with geeky details. But failing to understand how they work can keep your scripts from running.

Warning DangerAnd even when you *do* understand .. they can still cause problems. (Uh, more on that later.)

I mean, used incorrectly, chmod (the unix command that sets permissions on files & directories) .. can even trash your whole server .. when used to do things like I'm trying to do ..

.. which is to effect changes to the permissions of ALL the files & directories contained within a certain master-directory. With great-power comes great-danger. (Think thermo-nuclear.)

I almost ran this directory-wide command from the wrong directory. That woulda been ugly. No easy way to recover. (Shoot me now.) But I caught myself. (It was late & I was tired.)

Used to be .. I was always on *high-alert* when working with/in the shell. But now that I've become more comfortable there, I've lost that sense of painstaking-vigilance I used to have. (Fear of trashing the server.)

Linux (a variant of Unix) recognizes 3 types of users »

  1. the owner (.. of the file/script/directory/folder. That's me.)
  2. a group member (.. formally assigned as such. Generally people you know & trust.)
  3. everybody else (.. including the dregs of society. Others.)

Here it might help to visualize a 3x4 grid, with 12 possible values. Based on our permission settings, each one of these 3 types of users can do 1 or more (or none) of 3 possible actions:

  1. nothing (.. no action permitted)
  2. read (.. the file or directory-contents)
  3. write (.. to the file/script or directory)
  4. execute (.. the script)

MODx Content Management System CMS» MODx Revolution CMS has Arrived

Now, if you've been faithfully following along, you know I've been learning to program with PHP. (Happy holidays, by the way.)

And one of the reasons I want to learn PHP is cuz of the (very cool) » MODx CMS.

[ CMS = Content Management System. ]

The coding studs at MODx have released a new version (2.0) called » Revolution, which was built from scratch, using all the latest/coolest stuff (technologies). Always nice to start from scratch with the latest technologies, tho normally impractical. (If I could start over .. the site, with what I know now. Ooh la la!)

••• today's entry continues here below •••

Whereas Drupal (one of the most popular open-source CMS'es) seems to be preferred by those who consider themselves a developer, and Joomla (probably the single most popular open-source CMS in the universe) seems to be preferred by designers .. MODx seems to fuse the best of both worlds. This is what I'd like to verify for myself.

Anyway, Revolution has been released. (It's actually at » v2.0.6) Released back in July at v2.0. I figure 6 months is enough time to identify (& squash) the nastier bugs.

Revo was built with PHP. It uses all Object-Oriented Programming (OOP). I've long felt that proficiency with 'Revo' would be a nice addition to the Rad toolkit. It has an elegant & stylish back-end, based on Javascript. Downright slick.

[ I am proficient with both Movable Type and the YaBB forum .. both are Perl-based scripts. ]

So anyway, I used the wget command from my server's shell (bash) to transfer the MODx Revo archive (*.zip) DIRECTLY to my server. In other words, the file never touched my local hard drive. Never did this before. It is cool, fast & simple. Saves an unnecessary step and less chance of corruption.

» Setting Directory & File Permissions Recursively via Linux Shell

But I was having one problem after another trying to get it installed. And I knew the problem was due to permissions set TOO HIGH.

Now, normally setting permissions too high is not going to keep your scripts from running. Normally it just represents a security risk. So I was scratching my head.

But it seems that suPHP (which I use as my default PHP handler) refuses to run scripts (at all) if permissions are set too high. suPHP will simply throw you a vague 500 server error and give you nada-clue to help identify the problem.

Most people do not use/run suPHP. They simply run PHP scripts as an Apache mod, using (looser) Apache user rights. Which means your PHP scripts need group-write permissions (directories » 775 and files » 664).

And this is exactly what you get when you unzip the MODx installation archive on your server.

But .. if you're running suPHP (like me), it will throw you a nasty 500 server error .. the moment you (try to) launch the installer. Pretty depressing. Definite mood killer.

Felt like like suPHP was saying, "Dude, it would be too dangerous to let you run that script. Like giving a gun to a kid. Come back when you have your sh!t together." 

The important thing to note in this post .. is that suPHP likes/wants » directories = 755 and files = 644. (Seared into my consciousness.) Good info can be found at post #5 here.

I was able to massage permissions on enough key files & folders to get the installation started .. but not enough to finish it. Kept sticking at testing the database. No error, nothing. Dead in the water. =(

The problem here is not so much permissions set to high, but rather HOW TO LOWER them to the correct settings .. without having to do them all manually, by hand, which would take forever and give your brain carpel-tunnel.

Thanks be unto Mr. Magoo (again) for providing the magic script. He is the author of the Guide to Linux and others you find hosted here.

This shell-mojo alone is worth the cost of today's entry. To be clear .. we're talking bash on Linux using puTTY launched from WinSCP.

find ./ -type d -exec chmod 755 {} \;
find ./ -type f -exec chmod 644 {} \;

The {} gets replaced by the name of each file that was found.
The ; tells find where the end of the exec command is.
The \ escapes the ; so the shell passes it into the command instead of interpreting it itself.

Nagasaki nuclear bomb explosionThe big CAVEAT (!) here is that you first need to navigate (cd) to the directory for which you want to run this script. Otherwise, it could reset permissions for files & folders not intended. Could be very bad for your server. (Let's not even think about it. It's the holidays.)

As a precaution, you could replace the ./ (which means » this directory) with the absolute path. That way it wouldn't matter WHERE you ran the script from.

By absolute path I mean something like » /home /user_name /public_html /target.

I was hoping I could set the default directory & file permissions while unzipping the archive. But nobody I asked thought that was possible. So the next best thing was running these bash shell scripts.

Note » I had to REFRESH the page-views (in WinSCP) before the new permissions showed up correctly. A little sweat there.

If I had to set them all by hand, I woulda been so over MODx. We're talking 450 directories and more than three thousand files.

Soon as I did, Revo installed like greased whale snot. Notta single error. Swore I heard angels singing. Also upgraded my copy of PHP & Apache web server to the latest releases (» 5.3.4 and 2.2.17) .. while I was at it. MySQL was upgraded later to the latest version supported by cPanel/WHM (5.1.51).

Somewhere during this, I installed the latest version of WampServer .. on my laptop. The first such upgrade in 18 months .. v2.1a, which comes with MySQL 5.5.8 as the default 32-bit install, plus PHP 5.3.3 and Apache 2.2.17. Uninstalled the old version first, instead of installing the new version over the old.

MySQL databaseNote that a new install of WampServer means you should set a root password for MySQL, which is done thusly:

Update MySQL database root password:
from MySQL console type:
use mysql <enter>
UPDATE user <enter>
SET Password=PASSWORD('EnterYourNewPasswordHere') <enter>
WHERE user='root'; <enter>
[Query OK, 1 row affected]
[Query OK, 0 rows affected]

Then you need to go into your /wamp folder and open folder » /apps, and find your copy of phpMyAdmin. In that folder, find the file » and edit the line » ['Servers'][$i]['password'] = ''; and put this same new password between the apostrophes, so it looks something like this » ['Servers'][$i]['password'] = 'YourNewMySQLRootPasswordHere';

Save file. Now you're good to go with phpMyAdmin. There are other ways to accomplish this, but this is the easiest. 

Then I installed a development copy of Revo on my laptop. No problem there. Created the database and user in phpMyAdmin. My VPS however, won't let me create a database in phpMyAdmin. Gotta use the MySQL module in cPanel.

After I upgraded everything, I deleted the previously installed copy of Revo (on my VPS), deleted the database, and started over from scratch. Mere minutes to create a new datbase & install Revo .. after I knew what I was doing (.. with correct permissions, for both files & directories).

Let the revolution begin! Somebody call Che & Mao. The journey of a thousand miles begins with a single install.

One hundred dollar bill Benjamin Franklin» Money & Drupal

I was also curious about this "million dollars in bootstrap funds" that were poured into MODx Revolution. How does that work? I mean, I know revolutions cost money, right?

Worth noting before I close .. that Drupal 7 is currently at RC3. So it should be released shortly. Heard it was a monster upgrade.

Drupal is an impressive piece of software. And Dries is not afraid to break backward compatibility, which keeps Drupal from being based on the limitations of legacy code.

I just don't want to invest that much time into learning it. But I have installed it before (twice) and played around with it.

Yeah, Obama runs the White House on Drupal. But they have a whole TEAM running the site. Heck, maybe even two teams! In other words, Drupal is way more than I want or need.

The idea behind a CMS .. is that they provide you with powerful features .. without making you learn the technologies used to develop them.

Might be worth noting here that the most recent version of Dreamweaver (CS5) added support for both Drupal & Joomla. I have not played with these features - (I demo'ed CS5, but still use CS4) - but Dreamweaver is very good at adding coding support that simplifies complicated things (like Drupal). Definitely a factor worth considering.

Planets orbiting the sun» Why CMS's are Like the Sun

Okay, I'm in the Christmas spirit. Let me wax digitally philosophical before I close .. regarding CMS'es and the internet. One of the most interesting things I learned in nuclear power .. is that:

Fission is when you SPLIT a big/heavy atom (such as uranium or plutoium) into 2 smaller pieces (.. called fission fragments). This releases energy .. the kind that powers your local nuclear power plant.

Fusion is when you COMBINE two small/light nuclei (such as hydrogen or helium) into a larger nuclei. This is what the sun uses .. whose warmth you can feel some 93 million miles away. It's also what a hydrogen bomb uses.

Now fusion releases FAR MORE energy (per reaction) than fission. BUT .. fusion (.. what the sun uses) also requires the INPUT of far more energy .. to accomplish the reaction.

In other words (.. watch closely), it takes far more energy to » put-things-together .. than it does to » break-them-apart. But the pay-off is also far greater. Get it?

This is something you already know (.. at least, subconsciously). I'm talking about life (including marriage & divorce) & people & the internet & knowledge & skills & technology & CMS'es .. which bring people together (.. or at least their ideas + knowledge + know-how). Powerful technology.

You'll find the closer you look, the more Western physics looks like Eastern mysticism. Trippy.

For more along these lines, here's a Google search preconfigured for the query » install modx revolution linux vps suphp chmod 644

About this Entry

This page contains a single entry by Rad published on December 28, 2010 12:28 PM.

Winter Solstice & Sharply Contrasting Values | Liu Xiaobo was the previous entry in this blog.

A Walk in the Park is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.