• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Upgrading Apache, PHP and MySQL on CentOS with Plesk (level: Intermediate)

Did you find this information helpful?

  • Most helpful and comprehensive

    Votes: 0 0.0%
  • Very helpful, but could have been better

    Votes: 0 0.0%
  • Helpful, but lacking in certain areas

    Votes: 0 0.0%
  • Good, but I am looking for something else

    Votes: 0 0.0%

  • Total voters
    3

Mrinal KantiM

New Pleskian
I am writing this "How To" to provide the latest information on upgrading PHP and MySQL with Plesk (on CentOS) without using third-party repositories. I personally avoid using third-party repositories due to potential issues such as dependency-invasiveness, lack of prompt maintenance, reliability risk and lack of extensive support from the community. Though one may find some scattered (out)dated information in the knowledgebase (e.g.: http://kb.odin.com/en/1077), yet none of them are complete enough for a successful upgrade.

NOTE: Though this article is aimed towards a fresh installation on a newly provisioned server WITHOUT ANY DEPENDENCY ON ANY THIRD-PARTY REPOSITORIES (apart from RedHat), upgrades on existing servers are possible with a similar approach (minor tweaks).

The product versions that I am using are based on those reliably (read almost officially) available for CentOS as of today:

CentOS(x86_64): 5.5 (latest as of today)
Plesk: 9.5.2 (latest as of today)
Apache(httpd): 2.2.13 (SRPM available at http://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/RHWAS/SRPMS/)
PHP: 5.2.10 (SRPM available at http://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/RHWAS/SRPMS/) or 5.2.13 from http://oss.oracle.com/projects/php/files/EL5/
MySQL: 5.1.47 (RHEL 5 RPMs downloaded from http://www.mysql.com/downloads/mysql/)

Brief outline of the installation process:
1. Installation sequence of Apache, MySQL 5.1 and PHP.
2. Installation of Plesk
3. Backup of Plesk databases
4. Uninstallation of Plesk downloaded MySQL 5.0
5. Installtion of MySQL 5.1
6. Restoration of Plesk databases

1. Installation sequence of Apache, MySQL 5.1 and PHP.

Apache MySQL and PHP are not available in the base/minimal installation of CentOS. Download the latest version of these SRPMs/RPMs from the above links, build SRPMs ('rpmbuild --rebuild --clean <packagename.src.rpm>' or otherwise) in the following sequence and install them:
a) Apache 2.2.13 (httpd, mod_ssl)
b) MySQL 5.1 (MySQL-shared-compat ONLY but NOT MySQL-server or MySQL-client)
c) PHP 5.2.10 (php, php-cli, php-common, php-gd, php-imap, php-mbstring, php-mysql, php-pdo, php-xml)

Note: The above mentioned package RPMs (except for MySQL-shared-compat) are obtained by building the respective SRPMs and not downloaded from CentOS repository via yum. MySQL-shared-compat can be downloaded directly from the MySQL web site.

PHP 5.2.10 must be compiled with MySQL 5.1. (i.e. you must have MySQL 5.1 server RPM installed while building PHP. Don't forget to remove the MySQL 5.1 server RPM before installing Plesk).

I have deliberately omitted (for retaining focus) mentioning packages like perl-DBD-mysql which are also required and have dependencies on MySQL. Such packages, among others, may be rebuilt from their respective SRPMs after installing MySQL 5.1.

The 'devel' versions of these packages are optional and are required only during building the SRPMs. 'MySQL-shared-compat' is required for providing the backward compatibility required during this entire upgrade process. This is also required as a dependency for 'php-mysql'.

2. Installation of Plesk

Use the autoinstaller to install Plesk if you have a decent network connection. Optionally you may download the full installer for Plesk. In either case, the install process remains similar.
Choose a minimal set of Plesk components during installation. For example, you may select only the mandatory "Base packages of Plesk" and "Plesk Updater". The remaining packages can be installed later using the Plesk Updater. This is for two reasons:
a) We would like to keep the psa (Plesk) database size minimal to minimize risk during upgrade from MySQL 5.0 to 5.1 (see below).
b) We would like to verify that Plesk Updater works flawlessly after upgrade to MySQL 5.1

During installation, Plesk would download MySQL 5.0.x from the CentOS repository and configure the psa and phpMyAdmin databases. Remember we only have MySQL 5.1's 'shared-compat' which allows the installed PHP 5.2.10 to connect to MySQL 5.0.x even though it was compiled with MySQL 5.1. Other MySQL 5.1 packages (server and client) must not be present as they would prevent Plesk from downloading MySQL 5.0. Verify the Plesk installation by accessing the panel from your favorite browser. You should also complete the remaining setup process (like changing default password and admin contact info) in the browser.

At the end of this step, your package configuration should be:
- Apache 2.2.10 (httpd, mod_ssl)
- MySQL-shared-compat (v5.1.47), mysql (v5.0.x), mysql-server (v5.0.x)
- PHP 5.2.10 (php, php-cli, php-common, php-gd, php-imap, php-mbstring, php-mysql, php-pdo, php-xml)

3. Backup of Plesk databases

Backup the newly created databases - psa and phpmyadmin_xxxxx using your favorite backup tool. I used mysqldump. Plesk makes a couple of entries in 'mysql.db' and 'mysql.user' tables. But we would not be backing up mysql schema as both these table structures are different(extra columns) between MySQL 5.0 and 5.1. Once the backup is complete you may also want to backup the mysql data directory (/var/lib/mysql) just in case.

Note: If you are upgrading MySQL on an existing Plesk installation AND have already created a few databases using Plesk, you may also want to backup the mysql.db and mysql.user tables along with those databases. These may be restored by replacing the INSERT statements of step 6.

4. Uninstallation of Plesk downloaded MySQL 5.0

Nuke the Plesk downloaded MySQL packages (mysql, mysql-server) as follows
rpm -e --nodeps mysql mysql-server
You should also delete/rename the MySQL data directory (/var/lib/mysql) after you have a backup. Create a new /etc/my.cnf with all final settings before proceeding.

5. Installation of MySQL 5.1

You may now install MySQL 5.1 RPMs (MySQL-client, MySQL-server) from the MySQL website (or compiled from SRPM as the case may be). If you are installing these RPMs using yum, then yum would automatically start the mysql server and create the data directory afresh based upon the settings of /etc/my.cnf.

MySQL 5.1 uses the service name 'mysql' instead of 'mysqld'. So you may want to rename the service and/or create necessary sym links.

6. Restoration of Plesk databases

Plesk renames the 'root' account of mysql to 'admin'. Since we have not backed up the mysql schema, we would have to do this manually.
(Some users may want to start MySQL with the 'skip_grant_table' options but this also disables all plugins which can be potentially problematic in certain cases like if you are running innodb as a plugin)

mysql> UPDATE mysql.user SET User='admin' WHERE User='root';
mysql> UPDATE mysql.user SET Password=PASSWORD('myAdminPassword') WHERE User='admin';
mysql> FLUSH PRIVILEGES;

Import the psa and phpmyadmin_xxxxx schemas that you had backed up earlier in step 3. This should not create any issues as these schemas do not exist in the newly created data directory. Make sure that Parallels Panel PHPMyAdmin user exists in mysql.user table and has right password and privileges. Username and password can be found in /usr/local/psa/admin/htdocs/domains/databases/phpMyAdmin/libraries/config.default.php. Below are the relevant insert statements (Remember to replace the xxxxx's):

mysql> USE 'mysql';
mysql> INSERT INTO db VALUES ('localhost','phpmyadmin_xxxxx','pma_xxxxx', 'Y','Y','Y','Y','N','N','N','N','N','N','N', 'N','N','N','N','N','N','N','N');
mysql> INSERT INTO user VALUES ('localhost','pma_xxxxx',password('xxxxxY'), 'N','N','N','N','N','N','N','N', 'N','N','N','N','N','N','N','N','N','N', 'N','N','N','N','N','N','N','N','N','N', '','','','',0,0,0,0);
mysql> FLUSH PRIVILEGES;
NOTE: In the above statements the password string has one extra character.

Remember to complete the MySQL post installation tasks as advised at: http://dev.mysql.com/doc/refman/5.1/en/default-privileges.html. Restart the MySQL database normally (if you have used 'skip_grant_table'). You may now install other useful plesk packages using the Plesk Updater to verify the upgrade.

FINALLY WE ARE ALL SET AND DONE. The entire upgrade process is with SELinux in enabled/enforcing state all the while.

NOTE: You may notice a nagging warning in phpMyAdmin which says - "Your PHP MySQL library version 5.0.90 differs from your MySQL server version 5.1.47. This may cause unpredictable behavior."
Apparently, I have not faced any issues so far because of this and this issue is only with the Plesk installed version of phpMyAdmin. But if you are looking for further troubleshooting you may find this information helpful - "Plesk panel itself uses separate apache server copy with other compiled-in PHP" (from http://kb.odin.com/en/6284). All concerns can be put to rest after you have verified the upgrade using a phpinfo.php file in your domain which should display the PHP version 5.2.10 and MySQL Client API version as 5.1.47.

I shall try my best to keep this information up-to-date. In the meanwhile, if you find this helpful or have any criticism, please post them in this thread. I would recommend all troubleshooting request to be posted in "Parallels Plesk Panel 9.5 for Linux/UNIX Troubleshooting Issues" sub-forum and use this thread ONLY for enhancing this article.

- Mrinal
 
Last edited:
This is good information, but I still prefer 3rd party repos (e.g. Atomic or Remi) to easily keep my PHP/MySQL packages updated ...
 
This is good information, but I still prefer 3rd party repos (e.g. Atomic or Remi) to easily keep my PHP/MySQL packages updated ...

Within a given context, each approach has its own advantages and disadvantages.

It depends on the purpose of the PHP/MySQL/Plesk installation. For example, if one is a shared hosting provider (or running non-critical apps) whose requirements are limited to the packages provided by the 3rd party repositories, then they can gain from the ease of upgrade and also woo customers by providing the latest version of packages.

But if one is looking for a stable platform for deploying critical applications where maintaining the stability, compatibility and reliability of the OS is far more critical than ease of upgrade, then there are fewer choices for upgrade.

To a great extent, the choice is also influenced by where one would want to invest his trust, time and effort. Whether its on defining a process based on reliable/official sources or on micro-managing updates from a bunch of lesser reliable sources (risking reliability and compatibility of the entire OS).
 
Last edited:
Will I be able to upgrade Plesk, if I upgrade my MySQL this way?
 
Will I be able to upgrade Plesk, if I upgrade my MySQL this way?

Since I am already using the latest version of Plesk, I am yet to try out the Plesk upgrade process. I suggest you watch this space until the next Plesk version is released and I have verified the upgrade.

In the meanwhile, if your are following the above mentioned process on an older version of Plesk, you can try using the Plesk Updater for upgrading Plesk and let us know your experience. If you have followed the earlier instructions carefully, you would have noticed that we have already verified the Plesk Updater functionality while adding Plesk components. But in case you anticipate any issues, you can also try temporarily downgrading MySQL to v5.0 during Plesk upgrade. The following process (lengthy but safer) outlines the detail steps for upgrading Plesk:

1. Backup the MySQL 5.1 databases i.e. 'psa', 'phpmyadmin_xxxxx' and any other database that you may have created after shutting down Plesk. Also backup the 'mysql.db' and 'mysql.user' tables as SQL scripts with the replace option (instead of insert). Ensure that you are not using any of the MySQL 5.1 specific backup options. Backup your /etc/my.cnf.

2. Uninstall MySQL 5.1 packages and delete the MySQL data directory. You may retain the 'MySQL-shared-compat' package as removing this might break the compatibility with PHP. Remove the backed up /etc/my.cnf

3. Install 'mysql' and 'mysql-server' packages (presumably v5.0.x) using yum from the official CentOS repository. This should recreate the MySQL data directory.

4. Import the backed up databases - 'psa' and 'phpmyadmin_xxxxx' only along with 'mysql.db' and 'mysql.user' tables into the newly installed MySQL (v5.0.x). This should not create any issues even though you are downgrading. This is because Plesk on CentOS is meant for MySQL 5.0 and should not be using any MySQL 5.1 features. So the dump that you obtained in Step 1 should be fully compatible with MySQL 5.0. Note that we are not importing any user created databases (which may use MySQL 5.1 features) in this step.

Watch out for the column count differences across MySQL versions while importing 'mysql.db' and 'mysql.user' tables.

5. Run the upgrade in your preferred way (i.e. using Plesk Updater or otherwise). This should not be an issue as we are upgrading Plesk using the officially supported MySQL database version (i.e. v5.0). PHP 5.2 should not create any major issues as Plesk uses its own version of PHP.

6. After the upgrade is complete, backup the 'psa' and 'phpmydmin_xxxxx' databases. It is unlikely that the Plesk update process has altered the 'mysql.db' and 'mysql.user' tables, so we need not backup these two tables again.

7. Remove the 'mysql' and 'mysql-server' packages after shutting down Plesk. Also remove the data directory.

8. Restore the /etc/my.cnf that you have backed up in Step 1. Install the MySQL 5.1 packages as usual.

9. Import 'mysql.db', 'mysql.user' tables (from Step 1) and the 'psa' and 'phpmyadmin_xxxxx' databases (from Step 6) along with other databases (from Step 1).

NOTE: This process may appear long and intimidating at first. So you may try this only if you face any issues with the usual option of upgrading Plesk using the Plesk Updater on MySQL 5.1.

Since we are using MySQL 5.0 during the Plesk upgrade, the chances of failure are immensely reduced as compared to upgrading Plesk while being on MySQL 5.1

I am assuming that the frequency of Plesk upgrade on a typical production environment is once a year or less. I shall be updating this post with my experience once I personally upgrade Plesk.
 
Last edited:
Back
Top