Plesk Linux: Enable NGINX and HTTP/2
27.02.2019
Support Wissensdatenbank
Follow these instructions to enable Nginx with HTTP/2 and ALPN on Plesk for Linux. These instructions are designed to activate NGINX as quickly as possible and without major interruption. The execution is at your own risk. As with all instructions, you should perform a full server backup first.
- Disable the debug mode of Plesk/opt/psa/admin/conf/panel.ini
[debug]
; Enable debug mode (do not use in production environment)
;enabled = off - In Plesk under ‘Tools & Settings => Apache Webserver’ set the following values:Restart
Apache interval to 600000 seconds
Activate
Apache
module remoteip - In Plesk under ‘Tools & Settings => IP Addresses’ click on Reread IP.Any IP problems must be solved!
Open the SSH console and check with the command below if all displayed IP addresses match the Plesk output.
# ifconfig - Execute the following SSH command (depending on the server load you can also increase the value to 64000
)/usr/local/psa/admin/sbin/websrv_ulimits -s 32000This
process can take several hours! - Change the file /etc/security/limits.conf
:root soft nofile 65535root
hard nofile 65535Logoff the server and log on again and execute the following command:
# ulimit -n65535Ifthe value is not accepted, a complete server restart is required. Check whether the value was then transferred
- install NGINX via Plesk under ‘Tools & Settings => Updates and Upgrade => Add / Remove Components => Web hosting => Nginx web server and reverse proxy server’
- Check for old configuration files before migrating to the new datacenter and remove the listed files
:# grep -r ‘62.146.’ /var/www/vhosts/system/*/conf/*.conf#
grep -r ‘62.146.’ /etc/nginx/plesk.conf.d/ - Run the following SSH commands
:# /usr/local/psa/admin/sbin/nginxmng –status#
/usr/local/psa/admin/sbin/nginxmng –enableThis
process can take several hours! - Check with the following command whether the value set under point 4 was taken over
:grep ‘Max open files’ /proc/$(cat /var/run/nginx.pid)/limits - Change the Apache2.conf file. You need to replace the %h with %a
:LogFormat “%h %l %u %t \”%r\” %>s %O \”%{Referer}i\”\”%{User-Agent}i\”” combinedLogFormat
“%a %l %u %t \”%r\” %>s %O \”%{Referer}i\””\”%{User-Agent}i\”” combined
- Now activate http2 from NGINX#
plesk bin http2_pref enableThis
process takes as long as step 7. Even if Plesk has already indicated that this is done, all configuration files are adjusted in the background.
As soon as no more changes are written to the subfolders, the process is completed. The subfolders with all configurations are/etc/apache2/plesk.conf.d/etc/nginx/plesk
.conf.d - After you have waited long enough (advantageous 12 hours), you can execute the following command to test NGINX
:# nginx -tNo
error must be displayed now, otherwise something went wrong. Then you should interrupt now and contact us - Now restart Apache2 and NGINX by hand
:# service apache2 reload#
service nginx reloadIf
the reload
should
work without problems, you can then issue the following commands:# service apache2 restart#
service nginx restart - In Plesk under ‘Tools & Settings => Apache Webserver’ set the following values:Apache
restart interval to 60 seconds - Tip: You can use our nginx.conf file. The file can be found at /etc/nginx/nginx.conf.
You can download our template from the following link:
admin.firestorm.ch => Support => Downloads => Rootserver => Plesk => Linux Then
check the configuration and restart Nginx:# nginx -t# nginx
restart - Now check HTTP/2 with the following link:
https://tools.keycdn.com/http2-test
- Disable the debug mode of Plesk/opt/psa/admin/conf/panel.ini
If you encounter problems we recommend to disable NGINX
:# /usr/local/psa/admin/sbin/nginxmng –disable