b2evolution Automated Install/Upgrade
Updated for version 6.6+
See the online manual for additional information.
Purpose
This document describes how you can most easily automate the installation of b2evolution on a hosting account.
This document also addresses automated upgrade of b2evolution.
Intended audience
- Web hosting providers
- Web hosting tool providers
Operating environment
b2evolution is a PHP + MySQL web application. Please see our System Requirements page for details.
Basics
Automated installation of web applications such as b2evolution typically involves these steps:
- Place the application files in the destination directory.
- Create a MySQL User, Database and privileges of the user on the database.
- Run the install/setup script of the application.
- Delete the installer.
Recommended Auto Install procedure
1. Place the application files in the destination directory
We recommend you prompt the user for a directory to install b2evolution into. If he provides an empty directory, b2evolution would be installed in his web root. This is the recommended default as b2evolution is a complete engine allowing to run a complete website (or even more if there are domain aliases pointing to the same folder.)
Let's assume the user chose to install into the root folder (www/).
Once the destination directory selected/created, you need to copy all the contents of the b2evolution package into the destination directory www/.
File permissions
You should make sure that the contents of the www/media/ directory are writable by PHP. This is the place where the user can upload pictures to insert in his blog posts, etc.
2. Create a MySQL database
You will need to provide b2evolution with a database where it will create its own tables.
3. Run the install script
At this point you can call b2evolution's install script through an HTTP GET request (wget, cURL, etc..) of this form:
http://example.com/install/index.php?locale=en-US&action=newdb&create_sample_contents=full
Use this form to generate an automated install test URL:
.htaccess
b2evolution comes with a sample.htaccess file that it will try to copy to .htaccess. This will fail if there is already a .htaccess file present. Please make sure b2evolution can install its own .htaccess file or many features related to parsing extended URLs will fail.
Detect errors:
If you parse the output of the installer, you will find that potential errors will be marked in <evo:error>...</evo:error> and warnigns with <evo:warning>...</evo:warning>.
Here is a list of all possible errors & warnings:
- <evo:error>ERROR: Impossible to rename
/media/users/admin/
to /media/users/xyz/
.</evo:error>
- <evo:error>ERROR: Impossible to use "xyz" for the admin account. Using "admin" instead.</evo:error>
- <evo:error>Logins can only contain letters, digits and the following characters: _ . -</evo:error>
- <evo:error>Logins cannot start with "usr_", this prefix is reserved for system use.</evo:error>
- <evo:error>The minimum password length is 5 characters.</evo:error>
- <evo:error>Passwords cannot contain the characters <, > and &.</evo:error>
- <evo:error>The email address is invalid.</evo:error>
- <evo:error>There is already a file called .htaccess at the blog root. If you don't specifically need this file, it is recommended that you delete it or rename it to old.htaccess before you continue. This will allow b2evolution to create a new .htaccess file that is optimized for best results.</evo:error>
- <evo:error>ERROR!<br><b>Again, we recommend you remove this file before continuing. If you chose to keep it, b2evolution will probably still work, but for optimization you should follow <a href="http://b2evolution.net/man/htaccess-file" target="_blank">these instructions</a>.</b></evo:error>
- <evo:error>ERROR!<br><b>Cannot find file [ sample.htaccess ] in your base url folder.</b></evo:error>
- <evo:error>ERROR!<br><b>Failed to copy files!</b></evo:error>
- <evo:error>ERROR!<br><b>http://example.com/install/test/index.html was not found as expected.</b></evo:error>
- <evo:error>ERROR!<br><b>Test was successful, but failed to copy .htaccess into baseurl directory!</b></evo:error>
- <evo:error>The DB schema has been changed since confirmation.</evo:error>
- <evo:error>b2evolution cannot be installed, because of the following errors:</evo:error>
- <evo:error>It seems that the database config settings you entered don't work. Please check them carefully and try again...</evo:error>
- <evo:error>You must pass db_config params or create a <code>/conf/_basic_config.php</code> file before calling the installer.</evo:error>
- <evo:error>Could not load original conf file [/conf/_basic_config.php]. Is it missing?</evo:error>
- <evo:error>No default time zone is set. Please open PHP.ini and set the value of 'date.timezone' (Example: date.timezone = Europe/Paris) or open /conf/_advanced.php and set the value of $date_default_timezone (Example: $date_default_timezone = 'Europe/Paris';)</evo:error>
- <evo:error>ERROR: Impossible to connect to Database.</evo:error>
- <evo:error>Check your database config settings below and update them if necessary...</evo:error>
- <evo:error>In order to install b2evolution with the en-US locale, your MySQL needs to support the utf-8 connection charset. (mysqli::set_charset(utf8))</evo:error>
- <evo:error>Upgrade failed!</evo:error>
- <evo:warning>OOPS! It seems b2evolution is already installed!</evo:warning>
- <evo:warning>Already installed.</evo:warning>
- <evo:warning>Not Enabled: You should create at least one question!</evo:warning>
- <evo:warning>WARNING: this plugin can only work once you download the GeoLite Country DB database. Go to the plugin settings to download it.</evo:warning>
- <evo:warning>You must configure a ping service URL before the plugin can be enabled.</evo:warning>
Detect success:
You can detect that installation has been successful by parsing the output and locating the string <evo:password> .
Furthermore, you can parse out the password that has been created for the user by parsing it out between <evo:password> and </evo:password>. Example:
<evo:login>admin</evo:login>
<evo:password>Htf8s*d/Kp$q6</evo:password>
4. Delete the install folder
At this point, the www/install/ folder is no longer needed. We recommend you delete it, both to save space and improve security.
Note: when upgrading, you will need a new version of the install folder. So there is really no point in keeping the old one.
Recommended Auto Upgrade procedure
Any newer version of b2evolution can upgrade its database from any older version. It will also refuse to update if for some reason you try to "downgrade" it.
0. Detecting which version of b2evolution is installed
Open the file www/conf/_application.php and parse out the line that says:
$app_version = '6.1.0-alpha';
You can safely ignore the part after the hyphen (-). The version number will always change when a new version is released.
You can compare this version number with the new one you have available.
Note: if using PHP, you can use version_compare() which does all the work for you.
1. Getting confirmation that the user wants to upgrade
You should warn the user that any customizations he may have added to his existing b2evolution may not work properly with the new version. This especially applies to custom skins, custom plugins and custom locales (translations).
Optionally, you may want to provide checkboxes for the following:
- Reset skins
- Reset plugins
- Reset locales (translations)
2. Replacing the files
Delete all files & folders from the b2evolution root folder except:
- www/media/ (where the user has uploaded his content files).
- If the user hasn't explicitely requested a reset of these, also keep:
- www/skins/
- www/plugins/
- www/locales/
- www/conf/_basic_config.php (You need to keep the basic config, otherwise b2evolution cannot upgrade)
After that, copy all files from the new b2evolution's distribution package.
3. Upgrading the database
At this point you can call b2evolution's install script through an HTTP GET request (wget, cURL, etc..) of this form:
http://example.com/install/index.php?locale=en-US&action=evoupgrade
Use this form to generate an automated upgrade test URL:
4. Delete the install folder
At this point, the www/install/ folder is no longer needed. We recommend you delete it, both to save space and improve security.
Note: when upgrading again, you will need a new install folder. So there is really no point in keeping the old one.