Jump to content

installation - site/assets/*/ directories


bpz
 Share

Recommended Posts

Suggestion: Processwire should explicitly require the developer to create site/assets/{cache,logs,files,sessions} and set appropriate write permissions for the web server to those directories. Or raise an error when unable to write to them. Because I've had problems with session data not being saved and no error shown or logs written.

Link to comment
Share on other sites

Or raise an error when unable to write to them.

This is what it currently does. It's all handled by the installer (/install.php on a new installation). The profileImport() function creates these directories:

/site/assets/logs/

/site/assets/cache/

/site/assets/sessions/

/site/assets/files/

When the mkdir() function fails, it reports this message in red: "Error creating directory: $dir". The error message(s) would appear on the screen after you've entered your database information and clicked submit.

I had an experience with one web host where they had some automated process that came through regularly and changed the permissions of directories, without my knowledge. Of course, such an automated process isn't exactly CMS friendly.

Another situation where permissions on those directories could be lost is if you have a site running in one location, and then copy it to another. If you haven't transferred it in a way that retains permissions, you'd have to fix the permissions on those /assets/ directories (and files in them). If you have shell access, you could do something like this: chmod -R og+rw /site/assets

Is it possible you've run into something similar, or can you think of any other factors?

  • Like 1
Link to comment
Share on other sites

I see, it's partly my fault - I copied the whole website from dist to local without copying the assets directory, imported a DB dump - thus no install and its checks. And PW didn't give an error when failing to write sessions to an unexisting assets/sessions. That's where it should raise :)

Link to comment
Share on other sites

After successful installation and first login, PW isn't going to report errors on a production site in order to ensure security. When it comes to sessions, PW is delegating session control to PHP's session functions. I believe these will report errors (when PW & PHP will let them), but won't throw fatal errors/exceptions when a session can't be written. If you ever think an error might be occurring, edit your /site/config.php and change $config->debug = true; That will ensure that error messages are displayed. But having all error messages suppressed by default ($config->debug = false) is always recommended for security on any production site. Once your assets dir is writable, you'll also be able to find error messages in /site/assets/errors.txt, regardless of the debug state. Also add your email address to the $config->adminEmail in /site/config.php so that errors are emailed to you as well.

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

×
×
  • Create New...