Hi,
We currently have a Virtualmin Professional installation with about 165 Websites all running on Apache 2.4.37, PHP 7.2.14, and MariaDB 10.2.22, almost all of which use WordPress to power the Website. In addition, we have the Varnish cache server set up on port 80 and Apache on ports 8080 and 443, and SSL termination is handled by Apache so that Virtualmin can work its existing Let's Encrypt magic and then proxy requests (using Apache) from 443 to Varnish on port 80.
While this setup works, and is split across five different Web servers that all share home directories, Postfix and Dovecot configuration files, and other data, and are sitting behind a single load balancer, memory use on each machine is quite high out of a total of 8 GB RAM per machine, and thus for this reason and several others I am looking into switching from Apache to NGINX.
I have read all over the place on Virtualmin.com that it is recommended to use a fresh, newly-installed copy of Virtualmin when beginning an NGINX journey, but instead I am looking into ways to migrate our existing Websites (both SSL and non-SSL) from Apache to NGINX, preferably the virtual host configuration files and other things used by Apache.
Is this possible and could it perhaps be automated somehow so that we don't have to do this by hand to all 165 sites? At this point I don't care about downtime as we have a separate machine we use for testing and stuff that we could always backup and restore onto our production machines once everything is in place. But I am really looking hard at NGINX, and I've heard Virtualmin's support for it has improved greatly over the years, so I wanted to throw out this migration scenario to see what route I should take moving forward, or if it's even practical/possible given our current setup. Any insight or assistance you could provide would be very much appreciated. Thank you!
Comments
Submitted by hescominsoon on Sun, 03/03/2019 - 22:39 Pro Licensee Comment #1
only 8 gigs per machine? I would at the minimum double it. My lowest server runs 16 and i am migrating to 24-36 gigs of ram in the coming months.
Submitted by JEMEDIACORP on Sun, 03/03/2019 - 22:44 Pro Licensee Comment #2
Doubling the RAM would be nice but at this point we don't have the financial resources to be able to do so, especially as we are using Linode as our service provider and their prices get steep quite quickly. Plus, all of the important things, like Website files and MySQL databases, are hosted on other machines that do have 16 GB RAM and mounted (in the case of our GlusterFS filesystems) or configured to be used (in the case of MySQL/MariaDB) on our 8 GB Web nodes via the private network. So all the Web nodes are doing is essentially serving Web content via Apache and caching via Varnish while our backend machines do the heavy lifting.
Submitted by JamieCameron on Sun, 03/03/2019 - 23:18 Comment #3
Do you want to migrate from Apache to Nginx domain by domain on a single system? Unfortunately this isn't possible due to the way the webservers open port 80 - you'd have to do the whole system in one go.
Submitted by JEMEDIACORP on Sun, 03/03/2019 - 23:25 Pro Licensee Comment #4
Well, right now we have Virtualmin set up on only one of the machines in our Web cluster; the others mount the same filesystems Virtualmin has access to for things like home directory sharing, Postfix/Dovecot, etc. but everything is "controlled" from the Virtualmin system. Varnish is running on port 80 right now so NGINX would have to use 8080 and 443 which is currently what Apache is using. I didn't quite understand the part of your message about how Web servers open the port though, what did you mean by that? Would a global migration be possible as opposed to domain by domain? Or could we back up Virtualmin and restore it on a Virtualmin system that has NGINX configured instead of Apache, like would Virtualmin just recognize this and rewrite things during restore?
Submitted by JamieCameron on Tue, 03/05/2019 - 00:21 Comment #5
Yes, a global migration would be possible. Basically, you could do the following :
The down side though is that any custom apache settings, redirects or PHP versions will be lost.
Submitted by JEMEDIACORP on Tue, 03/05/2019 - 00:25 Pro Licensee Comment #6
How will the steps you outlined affect alias/sub-servers?
Submitted by JamieCameron on Wed, 03/06/2019 - 00:25 Comment #7
They will be preserved as they were before.
Submitted by JEMEDIACORP on Wed, 03/06/2019 - 00:29 Pro Licensee Comment #8
Oh good. One other question, right now all virtual servers use mod_fcgid. How would this translate over to NGINX?
Submitted by JEMEDIACORP on Tue, 05/07/2019 - 12:38 Pro Licensee Comment #9
Any update on this?
Submitted by JamieCameron on Sun, 05/12/2019 - 19:09 Comment #10
The PHP execution mode will be whatever is the default, which is typically mod_fcgid.
Submitted by JEMEDIACORP on Sun, 05/12/2019 - 19:57 Pro Licensee Comment #11
OK. I guess my next question here is, 95% of the sites we host under Virtualmin are WordPress installations with .htaccess files that WordPress writes automatically based on permalink settings and other such options. How would these work under NGINX?
Submitted by hescominsoon on Sun, 05/12/2019 - 19:59 Pro Licensee Comment #12
they should work fine..the .htaccess thing is not specific to apache. if you get php to run under nginx then WP and other php based scripts should run jsut fine as well.
Submitted by JEMEDIACORP on Sun, 05/12/2019 - 20:00 Pro Licensee Comment #13
Pardon my possible ignorance but how is .htaccess not specific to Apache? I mean the directives inside directly correlate to Apache-specific features and modules like mod_rewrite.
Submitted by hescominsoon on Sun, 05/12/2019 - 20:07 Pro Licensee Comment #14
nopers i sit corrected...:) nginx does not suport .htaccess at all. Those directives have to be put under nginx.conf or something similar. I ma not sure how virt can use nginx in a shared hosting environment...The sites that say they support nginx offer nginx on vps..meant for a single site. I saw a guide to running nginx in a shared environment for ubuntu 14.x....
Submitted by JEMEDIACORP on Sun, 05/12/2019 - 20:06 Pro Licensee Comment #15
Hmm, I mean if Virtualmin has support for NGINX I would think their implementation would be built to support shared hosting since Virtualmin is after all a shared hosting platform...can one of the Virtualmin devs chime in on this?
Submitted by hescominsoon on Sun, 05/12/2019 - 20:08 Pro Licensee Comment #16
virtualmin can be used in both shared or dedicated. another quick google search pulls this up: https://www.virtualmin.com/documentation/web/nginx
keep in mind virt can be either shared or dedicated...