Overview
Nginx is a high-performance web server known for its speed and efficiency, particularly well-suited for sites with high static content or environments with limited memory. For more details on Nginx, visit the Nginx Wiki.
Using Nginx
Once Nginx support is configured, you can manage virtual servers similar to Apache:
- Virtual server creation: When creating a new virtual server, select Nginx website enabled under Enabled features, instead of Apache website enabled.
- CLI API: Use
--virtualmin-nginxflag instead of--webfor non-SSL websites and--virtualmin-nginx-sslinstead of--sslfor SSL-enabled sites. - Remote API: Use the
virtualmin-nginx=parameter instead ofweb=.
Configuring Nginx support in Virtualmin
Clean installation as LEMP stack
- Automated installation: During Virtualmin installation, use the
--bundle LEMPoption with thevirtualmin-install.shscript. This sets up a LEMP (Linux, Nginx, MariaDB, PHP) stack. For more information, see the LAMP vs. LEMP documentation.
Manual webserver switch
Manual switching requires advanced configuration and is typically not recommended for most users because of its technical complexity.
Manual switch from Apache to Nginx
- Disable Apache: Disable Apache.
- Debian and derivatives
systemctl disable --now apache2 - EL systems
systemctl disable --now httpd
- Debian and derivatives
- Disable Apache website feature for all existing virtual servers
virtualmin disable-feature --all-domains --web --ssl --status --virtualmin-awstatsNote: Dependent features such as
statusandvirtualmin-awstatsmust also be disabled, as they rely on the webserver feature. Depending on your setup, there may be others. Adjust the command flags as needed. - Disable Apache and dependent Virtualmin global features
virtualmin set-global-feature --disable-feature web --disable-feature ssl --disable-feature virtualmin-htpasswdNote: Dependent features such as
virtualmin-htpasswdmust also be disabled, as they rely on the webserver feature. - Install Nginx and dependencies: Install Nginx and Nginx Virtualmin modules from your repository.
- Debian and derivatives
apt-get install nginx-full webmin-virtualmin-nginx webmin-virtualmin-nginx-ssl - EL systems
dnf install nginx webmin-virtualmin-nginx webmin-virtualmin-nginx-ssl
- Debian and derivatives
- Configure Virtualmin for Nginx
virtualmin-config-system --include Nginx - Enable Nginx as Virtualmin global feature
virtualmin set-global-feature --enable-feature virtualmin-nginx --enable-feature virtualmin-nginx-sslNote: Dependent features such as
virtualmin-htpasswdshould also be re-enabled if they were previously enabled and needed. - Enable Nginx website feature for all existing virtual servers
virtualmin enable-feature --all-domains --virtualmin-nginx --virtualmin-nginx-sslNote: You may also need to re-enable other features that were disabled in step 2, depending on your configuration.
Switching from Nginx to Apache
- Disable Nginx: Disable Nginx.
- EL systems and Debian derivatives
systemctl disable --now nginx
- EL systems and Debian derivatives
- Disable Nginx website feature for all existing virtual servers
virtualmin disable-feature --all-domains --virtualmin-nginx --virtualmin-nginx-ssl --status --virtualmin-awstatsNote: Dependent features such as
statusandvirtualmin-awstatsmust also be disabled, as they rely on the webserver feature. Depending on your setup, there may be others. Adjust the command flags as needed. - Disable Nginx and dependent Virtualmin global features
virtualmin set-global-feature --disable-feature virtualmin-nginx --disable-feature virtualmin-nginx-ssl --disable-feature virtualmin-htpasswdNote: Dependent features such as
virtualmin-htpasswdmust also be disabled, as they rely on the webserver feature. - Install Apache: Install the Apache package along with necessary modules.
- Debian and derivatives
apt-get install apache2 libapache2-mod-fcgid apache2-suexec-custom - EL systems
dnf install httpd mod_fcgid mod_ssl mod_http2
- Debian and derivatives
- Configure Virtualmin for Apache
virtualmin-config-system --include Apache - Enable Apache as Virtualmin global feature
virtualmin set-global-feature --enable-feature web --enable-feature sslNote: Dependent features such as
virtualmin-htpasswdshould also be re-enabled if they were previously enabled and needed. - Enable Apache website feature for all existing virtual servers
virtualmin enable-feature --all-domains --web --sslNote: You may also need to re-enable other features that were disabled in step 2, depending on your configuration.