Combining cPanel and Plesk for kicks and giggles.
Hello!
I work at Liquid Web and one day decided to try combining cPanel and Plesk.
This is totally not sanctioned by LW, and was done in my off-hours. Some have deemed this masochistic but I've been finding it quite fun -- and an excellent chance to learn more about the internal workings of cPanel and Plesk, something which I have really been craving.
I run into issues quite often with this, but I feel like this might be interesting to some of you. Please note that it took a lot of trial and error before I got to this. I've rolled back the server plenty of times to images that I've made during steps in the process; this is more of a condensed version of my project notes; do note the working directory of each command if it seems out of place.
Starting off
Spun up a 1GB cPanel VPS, nothing fancy.
First I disabled pretty much everything that might get in the way
Logged into WHM. Disabled pretty much everything in Service Manager except SSHD and MySQL. Disabled cPanel, removed httpd symlinks in /etc and /usr/sbin because they'd probably mess up when Plesk tries to install its own httpd:
I removed exim and dovecot with yum. Stopped and disabled cpanellogd (with chkconfig)
Found this cPanel article (thanks guys!): How to Replace MySQL with MariaDB - cPanel Knowledge Base - cPanel Documentation
Previous Plesk installs failed because I was missing libmcrypt.
Did a bit of troubleshooting to figure it out: Tried installing it but it didn't quite work the first time..
/usr/bin/sw-engine is trying to load libmcrypt.so.4...where is it trying to load from? Stracing:
I couldn't find it with yum..Installed epel-release via yum. Now with epel repo we have several more mcrypt packages including libmcrypt available via yum Installed libmcrypt (yum install libmcrypt)
This spit out some garbage (good I think?)
Success! We're now running MariaDB...Went to
I was able to log in to WHM. Tried going to phpMyAdmin, no dice.
I can now load phpMyAdmin in WHM. I was able to create a cPanel account successfully as well. I ran /scripts/check_cpanel_rpms --targets=exim and confirmed that I wanted to fix it. It only included what I specified, which was exim. Handy! Now exim is working with cPanel again, far as I can tell. Popped open WHM and reenabled Exim, and switched update preferences to "Manual Updates Only" for pretty much everything. Also switched cPanel's httpd to port 81. I had to go home for the day, but the next day...I tried to get dual Apache running.
I've got both running, it seems. cPanel's is on port 81 and Plesk's is on port 80. However the cPanel httpd service is technically disabled..
Enabled httpd in WHM and it took forever to start...until I manually ran /scripts/restartsrv_httpd after which it finished. Created a disk image and ran an EasyApache. As expected, it did not go well, and reverted the changes that it had made. However, PHP's running on cPanel's Apache again! Tried setting up WordPress.
driveroot/scripts/check_mysql.patch:
driveroot/scripts/cleanupmysqlprivs.patch
There's a lot more that I need to do to correct cPanel's assumption that the MySQL admin user is root, but this is a start. I also made a scripts folder within my PATCHES folder to store functions that I can invoke to do important things, such as scripts/setup_mysql_password_file.sh
Main issues: - Trying to restart httpd is a total mess. It takes fiddling around to even get things to even sort-of since the systemctl targets are either to Plesk or something else. I'm considering trying to replace it with litespeed (if I can get a license). EasyApache runs but will never complete, and much is broken including anything that involves invoking or restarting httpd. The PHP version that cPanel Apache is running is actually what came with Plesk. I don't know if litespeed changes the binary names, but as long as I can separate Plesk Apache from cPanel's Apache then I may be able to get things working more stably. - MySQL drivers are not working out very well at the moment, and WordPress on cPanel is not liking mysqlnd. - My Plesk license expired, so I contacted Plesk sales and they gave me one that will expire on May 15th, 2016. I'll probably run into some point where they won't give me any more license keys though. - Actually, this entire server is the main issue. But for all that should have broken, I can say a lot is still working because of cPanel's choice for file locations, vs Plesk's (Plesk's is far closer to a bare LAMP stack than cPanel, although still very dissimilar). This is letting things still continue to function fairly well. Hope you got a kick out of this, I'll post updates if you want. I'll also probably cross-post this somewhere if I ever get around to starting a blog. The real fun in this is getting things to actually work, and all the things I'm learning about cPanel in the process. (Some of Plesk too, but I have had far more experience with cPanel, about 11 months worth on May 1st, so cPanel is where I'm making the most progress.)
root@host [~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
root@host [~]# /usr/local/cpanel/cpanel -V
54.0 (build 21)
root@host [~]# free -mh
total used free shared buff/cache available
Mem: 851M 168M 130M 66M 551M 477M
Swap: 2.0G 177M 1.8G
First I disabled pretty much everything that might get in the way
root@host [~]# csf -x
csf and lfd have been disabled
root@host [~]#
root@host [/etc]# cp yum.conf{,.aburk.bak}
root@host [/etc]# nano yum.conf
root@host [/etc]# diff yum.conf{,.aburk.bak}
2c2
< #exclude=courier* dovecot* exim* filesystem httpd* mod_ssl* mydns* mysql* nsd* php* proftpd* pure-ftpd* spamassassin* squirrelmail*
---
> exclude=courier* dovecot* exim* filesystem httpd* mod_ssl* mydns* mysql* nsd* php* proftpd* pure-ftpd* spamassassin* squirrelmail*
root@host [/etc]# mysqldump --all-databases > /home/temp/cPanel.sql
root@host [/etc]# cp ~/.my.cnf /home/temp/.my.cnf
Logged into WHM. Disabled pretty much everything in Service Manager except SSHD and MySQL. Disabled cPanel, removed httpd symlinks in /etc and /usr/sbin because they'd probably mess up when Plesk tries to install its own httpd:
root@host [/etc]# service cpanel stop
Redirecting to /bin/systemctl stop cpanel.service
root@host [/etc]# chkconfig cpanel off
Note: Forwarding request to 'systemctl disable cpanel.service'.
Removed symlink /etc/systemd/system/multi-user.target.wants/cpanel.service.
root@host [/etc]# rm httpd
rm: remove symbolic link "httpd"? y
root@host [/usr/sbin]# rm httpd
rm: remove symbolic link "httpd"? y
root@host [/var/lib]# cp -a mysql{,.aburk.bak}
I removed exim and dovecot with yum. Stopped and disabled cpanellogd (with chkconfig)
/usr/local/cpanel/scripts/check_cpanel_rpms --list-only --long-list
[2016-04-02 13:35:17 -0400] Problems were detected with cPanel-provided files which are RPM controlled.
[2016-04-02 13:35:17 -0400] If you did not make these changes intentionally, you can correct them by running:
[2016-04-02 13:35:17 -0400]
[2016-04-02 13:35:17 -0400] > /usr/local/cpanel/scripts/check_cpanel_rpms --fix
[2016-04-02 13:35:17 -0400] The following RPMs are missing from your system:
[2016-04-02 13:35:17 -0400] MySQL56-client-5.6.29-1.cp1148
[2016-04-02 13:35:17 -0400] MySQL56-server-5.6.29-1.cp1148
[2016-04-02 13:35:17 -0400] MySQL56-test-5.6.29-1.cp1148
[2016-04-02 13:35:17 -0400] exim-4.86.1-2.cp1154
[2016-04-02 13:35:18 -0400]
[2016-04-02 13:35:18 -0400] The following RPMs are unneeded on your system and should be uninstalled:
[2016-04-02 13:35:18 -0400] pure-ftpd-1.0.42-4.cp1154
Found this cPanel article (thanks guys!): How to Replace MySQL with MariaDB - cPanel Knowledge Base - cPanel Documentation
root@host [/scripts]# /scripts/update_local_rpm_versions --edit target_settings.MySQL50 uninstalled
root@host [/scripts]# /scripts/update_local_rpm_versions --edit target_settings.MySQL51 uninstalled
root@host [/scripts]# /scripts/update_local_rpm_versions --edit target_settings.MySQL55 uninstalled
root@host [/scripts]# /scripts/update_local_rpm_versions --edit target_settings.MySQL56 uninstalled
root@host [/scripts]# /scripts/check_cpanel_rpms --fix --targets=MySQL50,MySQL51,MySQL55,MySQL56
[2016-04-02 15:48:08 -0400]
[2016-04-02 15:48:08 -0400] Problems were detected with cPanel-provided files which are RPM controlled.
[2016-04-02 15:48:08 -0400] If you did not make these changes intentionally, you can correct them by running:
[2016-04-02 15:48:08 -0400]
[2016-04-02 15:48:08 -0400] > /usr/local/cpanel/scripts/check_cpanel_rpms --fix
[2016-04-02 15:48:08 -0400]
[2016-04-02 15:48:08 -0400] The following RPMs are unneeded on your system and should be uninstalled:
[2016-04-02 15:48:08 -0400] MySQL56-devel-5.6.29-1.cp1148
[2016-04-02 15:48:08 -0400] MySQL56-shared-5.6.29-1.cp1148
[2016-04-02 15:48:08 -0400] compat-MySQL50-shared-5.0.96-4.cp1136
[2016-04-02 15:48:08 -0400] compat-MySQL51-shared-5.1.73-1.cp1150
[2016-04-02 15:48:08 -0400] Removing 0 broken rpms:
[2016-04-02 15:48:08 -0400] rpm: no packages given for erase
[2016-04-02 15:48:08 -0400] No new RPMS needed for install
[2016-04-02 15:48:08 -0400] Disabling service monitoring.
[2016-04-02 15:48:10 -0400] Uninstalling unneeded rpms: compat-MySQL51-shared compat-MySQL50-shared MySQL56-shared MySQL56-devel
[2016-04-02 15:48:11 -0400] Restoring service monitoring.
Previous Plesk installs failed because I was missing libmcrypt.
===> Cumulative APS controller upgrade (final stage) has been started.
Trying to set up APS controller database... APS db accessibility check was skipped.
/usr/bin/sw-engine: error while loading shared libraries: libmcrypt.so.4: cannot open shared object file: No such file or directory
ERROR while trying to store APS controller db connection parameters into product db
Check the error reason(see log file: /var/log/plesk/install/plesk_12.5.30_installation.log), fix and try again
***** problem report *****
ERROR while trying to store APS controller db connection parameters into product db
Check the error reason(see log file: /var/log/plesk/install/plesk_12.5.30_installation.log), fix and try again
ERROR: An error occurred during performing of installation POST actions (see log for details).
Warning! Not all packages were installed.
Please check if your system services are operable.
Please resolve this issue and try installing the packages again.
If you cannot resolve the issue on your own, contact product technical support for assistance.
Did a bit of troubleshooting to figure it out: Tried installing it but it didn't quite work the first time..
root@host [~/cPlesk]# /usr/local/psa/bin/admin --show-password
/usr/bin/sw-engine: error while loading shared libraries: libmcrypt.so.4: cannot open shared object file: No such file or directory
root@host [~/cPlesk]# service psa status
is not running
root@host [~/cPlesk]# service psa start
Starting sw_engine service... failed
Starting sw_cp_server service... done
Starting mysql service... already started
Starting named service... not installed
Starting spamfilter service... not installed
Starting tomcat service... not installed
Starting apache service... done
Starting superserver service... done
Starting sw_engine service... failed
Starting drweb service... not installed
/usr/bin/sw-engine is trying to load libmcrypt.so.4...where is it trying to load from? Stracing:
root@host [~/cPlesk]# strace /usr/local/psa/bin/admin --show-password 2>&1 |grep libmcrypt
open("/usr/lib64/php/modules/sw-engine/libmcrypt.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib64/libboost-plesk-1.55.0/libmcrypt.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/tls/x86_64/libmcrypt.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/tls/libmcrypt.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/x86_64/libmcrypt.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libmcrypt.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib64/tls/x86_64/libmcrypt.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib64/tls/libmcrypt.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib64/x86_64/libmcrypt.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib64/libmcrypt.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
writev(2, [{"/usr/bin/sw-engine", 18}, {": ", 2}, {"error while loading shared libra"..., 36}, {": ", 2}, {"libmcrypt.so.4", 14}, {": ", 2}, {"cannot open shared object file", 30}, {": ", 2}, {"No such file or directory", 25}, {"\n", 1}], 10/usr/bin/sw-engine: error while loading shared libraries: libmcrypt.so.4: cannot open shared object file: No such file or directory
I couldn't find it with yum..Installed epel-release via yum. Now with epel repo we have several more mcrypt packages including libmcrypt available via yum Installed libmcrypt (yum install libmcrypt)
root@host [~/cPlesk]# /usr/local/psa/bin/admin --show-password
This spit out some garbage (good I think?)
root@host [~/cPlesk]# service psa start
Starting sw_engine service... done
Starting sw_cp_server service... already started
Starting mysql service... already started
Starting named service... not installed
Starting spamfilter service... not installed
Starting tomcat service... not installed
Starting apache service... already started
Starting superserver service... already started
Starting sw_engine service... already started
Starting drweb service... not installed
root@host [~/cPlesk]# service psa status
is running
root@host [~/cPlesk]# lsof -i:8443
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sw-cp-ser 16315 root 7u IPv4 274244 0t0 TCP *:pcsync-https (LISTEN)
sw-cp-ser 16315 root 9u IPv6 274246 0t0 TCP *:pcsync-https (LISTEN)
sw-cp-ser 16317 sw-cp-server 7u IPv4 274244 0t0 TCP *:pcsync-https (LISTEN)
sw-cp-ser 16317 sw-cp-server 9u IPv6 274246 0t0 TCP *:pcsync-https (LISTEN)
Success! We're now running MariaDB...Went to
root@host [~/cPlesk]# service cpanel start
Redirecting to /bin/systemctl start cpanel.service
root@host [~/cPlesk]#
root@host [~/cPlesk]# lsof -i:2087
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
cpsrvd 26871 root 4u IPv4 297131 0t0 TCP *:eli (LISTEN)
root@host [~/cPlesk]# lsof -i:2083
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
cpsrvd 26871 root 10u IPv4 297141 0t0 TCP *:radsec (LISTEN)
I was able to log in to WHM. Tried going to phpMyAdmin, no dice.
FILE=/root/.my.cnf
echo '[mysql]' > $FILE
echo 'user=admin' >> $FILE
echo "pass=$(cat /etc/psa/.psa.shadow)" >> $FILE
I can now load phpMyAdmin in WHM. I was able to create a cPanel account successfully as well. I ran /scripts/check_cpanel_rpms --targets=exim and confirmed that I wanted to fix it. It only included what I specified, which was exim. Handy! Now exim is working with cPanel again, far as I can tell. Popped open WHM and reenabled Exim, and switched update preferences to "Manual Updates Only" for pretty much everything. Also switched cPanel's httpd to port 81. I had to go home for the day, but the next day...I tried to get dual Apache running.
root@host [/home/cpplesk/public_html]# ps faux|grep [h]ttpd
root 10840 0.0 0.7 87872 6912 ? SNs Apr03 0:16 /usr/local/apache/bin/httpd -k graceful
nobody 11226 0.0 0.6 87620 5480 ? SN Apr03 0:16 \_ /usr/local/apache/bin/httpd -k graceful
nobody 11227 0.0 1.0 507908 9128 ? SNl Apr03 0:59 \_ /usr/local/apache/bin/httpd -k graceful
nobody 11228 0.0 0.7 573444 6764 ? SNl Apr03 0:59 \_ /usr/local/apache/bin/httpd -k graceful
nobody 11229 0.0 0.6 376836 5580 ? SNl Apr03 0:59 \_ /usr/local/apache/bin/httpd -k graceful
nobody 11230 0.0 0.6 442372 5540 ? SNl Apr03 0:58 \_ /usr/local/apache/bin/httpd -k graceful
nobody 11231 0.0 0.8 507908 7088 ? SNl Apr03 0:58 \_ /usr/local/apache/bin/httpd -k graceful
nobody 11232 0.0 1.0 442372 9120 ? SNl Apr03 0:59 \_ /usr/local/apache/bin/httpd -k graceful
nobody 10831 0.0 0.7 376836 6396 ? SNl 12:38 0:00 \_ /usr/local/apache/bin/httpd -k graceful
root 10735 0.1 1.0 251272 9088 ? Ss 12:38 0:00 /usr/sbin/httpd -DFOREGROUND
apache 10736 0.0 0.4 249980 4052 ? S 12:38 0:00 \_ /usr/sbin/httpd -DFOREGROUND
apache 10737 0.0 0.4 251020 3776 ? S 12:38 0:00 \_ /usr/sbin/httpd -DFOREGROUND
apache 10738 0.0 0.7 538100 6620 ? Sl 12:38 0:00 \_ /usr/sbin/httpd -DFOREGROUND
apache 10739 0.0 0.5 669172 4840 ? Sl 12:38 0:00 \_ /usr/sbin/httpd -DFOREGROUND
apache 10740 0.0 0.8 603636 7144 ? Sl 12:38 0:00 \_ /usr/sbin/httpd -DFOREGROUND
I've got both running, it seems. cPanel's is on port 81 and Plesk's is on port 80. However the cPanel httpd service is technically disabled..
root@host [/home/cpplesk/public_html]# /scripts/restartsrv_httpd
Waiting for "httpd" to stop "finished.
info [restartsrv_base] The service 'httpd' is disabled and the system will not attempt to restart it.
(XID wrkhux) The "httpd" service is disabled.
fcgi is borked and PHP wont run.
Enabled httpd in WHM and it took forever to start...until I manually ran /scripts/restartsrv_httpd after which it finished. Created a disk image and ran an EasyApache. As expected, it did not go well, and reverted the changes that it had made. However, PHP's running on cPanel's Apache again! Tried setting up WordPress.
driveroot/scripts/check_mysql.patch:
39,40c39,40
<
< my @output = `LANG=C $mysqlcheck -u root -m --silent --databases $db 2>&1`;
---
> my $mysql_username = `grep -Po "user=.*" /root/.my.cnf |awk -F= '{print $2}'|sed 's/^[ \t]*//;s/[ \t]*$//'`
> my @output = `LANG=C $mysqlcheck -u $mysql_username -m --silent --databases $db 2>&1`;
driveroot/scripts/cleanupmysqlprivs.patch
root@host [~/PATCHES]# cat driveroot/scripts/cleanupmysqlprivs.patch
4c4
<
---
> mysqladminuser=`grep -Po "user=.*" /root/.my.cnf |awk -F= '{print $2}'|sed 's/^[ \t]*//;s/[ \t]*$//'`
6,9c6,9
< update user set Create_priv='N' where Create_priv='Y' and User != 'root';
< update user set Create_tmp_table_priv='N' where Create_tmp_table_priv='Y' and User != 'root';
< update user set Lock_tables_priv='N' where Lock_tables_priv='Y' and User != 'root';
< update user set Execute_priv='N' where Execute_priv='Y' and User != 'root';
---
> update user set Create_priv='N' where Create_priv='Y' and User != '$mysqladminuser';
> update user set Create_tmp_table_priv='N' where Create_tmp_table_priv='Y' and User != '$mysqladminuser';
> update user set Lock_tables_priv='N' where Lock_tables_priv='Y' and User != '$mysqladminuser';
> update user set Execute_priv='N' where Execute_priv='Y' and User != '$mysqladminuser';
There's a lot more that I need to do to correct cPanel's assumption that the MySQL admin user is root, but this is a start. I also made a scripts folder within my PATCHES folder to store functions that I can invoke to do important things, such as scripts/setup_mysql_password_file.sh
#!/bin/bash
setup_mysql_password_file() {
FILE=/root/.my.cnf
echo '[mysql]' > $FILE
echo 'user=admin' >> $FILE
echo "pass=$(cat /etc/psa/.psa.shadow)" >> $FILE
}
Main issues: - Trying to restart httpd is a total mess. It takes fiddling around to even get things to even sort-of since the systemctl targets are either to Plesk or something else. I'm considering trying to replace it with litespeed (if I can get a license). EasyApache runs but will never complete, and much is broken including anything that involves invoking or restarting httpd. The PHP version that cPanel Apache is running is actually what came with Plesk. I don't know if litespeed changes the binary names, but as long as I can separate Plesk Apache from cPanel's Apache then I may be able to get things working more stably. - MySQL drivers are not working out very well at the moment, and WordPress on cPanel is not liking mysqlnd. - My Plesk license expired, so I contacted Plesk sales and they gave me one that will expire on May 15th, 2016. I'll probably run into some point where they won't give me any more license keys though. - Actually, this entire server is the main issue. But for all that should have broken, I can say a lot is still working because of cPanel's choice for file locations, vs Plesk's (Plesk's is far closer to a bare LAMP stack than cPanel, although still very dissimilar). This is letting things still continue to function fairly well. Hope you got a kick out of this, I'll post updates if you want. I'll also probably cross-post this somewhere if I ever get around to starting a blog. The real fun in this is getting things to actually work, and all the things I'm learning about cPanel in the process. (Some of Plesk too, but I have had far more experience with cPanel, about 11 months worth on May 1st, so cPanel is where I'm making the most progress.)
-
Hello, Thank you for taking the time to share your project here. While these types of projects are unsupported, I did want to point you towards using EasyApache 4 at some point if you have not already done so: EasyApache 4 - EasyApache 4 - cPanel Documentation I don't know that it will make restarting Apache any easier, but it's much different than EasyApache 3 so you may have fun exploring the changes. Thanks! 0 -
That's a person with too much time on their hands :) 0 -
That's a person with too much time on their hands :)
I wish! It's a fun learning exercise.0
Please sign in to leave a comment.
Comments
4 comments