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.
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)
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.
4. Uninstallation of Plesk downloaded MySQL 5.0
Nuke the Plesk downloaded MySQL packages (mysql, mysql-server) as follows
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)
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):
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.
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
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
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.rpm -e --nodeps mysql mysql-server
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):
NOTE: In the above statements the password string has one extra character.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;
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: