Nginx Upgrade
This guide applies to environments installed using the Nginx Deployment Guide, with Nginx installed in /usr/local/nginx/ and managed by systemd. Run the following commands as root.
The upgrade briefly stops Nginx. Perform it during a maintenance window. Replace only the Nginx executable, keeping existing proxy settings, certificates, and log rotation settings. Check compatibility separately if you use a custom installation path or modules.
Upgrade Steps
-
Check the Current Version and Configuration, and Back Up the Installation Directory
/usr/local/nginx/sbin/nginx -v/usr/local/nginx/sbin/nginx -tcp -a /usr/local/nginx /usr/local/nginx.bakIf
/usr/local/nginx.bakalready exists, move the previous backup elsewhere before running the backup command. Continue only after the configuration check and backup succeed. -
Download and Extract the Target Version
- Linux amd64
- Linux arm64
wget https://pdpublic.mingdao.com/private-deployment/offline/common/nginx-1.30.6-glibc2.17-amd64.tar.gztar -zxvf nginx-1.30.6-glibc2.17-amd64.tar.gzwget https://pdpublic.mingdao.com/private-deployment/offline/common/arm64/nginx-1.30.6-glibc2.17-arm64.tar.gztar -zxvf nginx-1.30.6-glibc2.17-arm64.tar.gz -
Check the Existing Configuration with the New Version
./nginx/sbin/nginx -v./nginx/sbin/nginx -p /usr/local/nginx/ -c /usr/local/nginx/conf/nginx.conf -tConfirm that the version is correct and that the output includes
syntax is okandtest is successful. Resolve any missing dependencies or incompatible settings before stopping the existing service. -
Stop the Service and Replace the Nginx Executable
systemctl stop nginxAfter confirming that the service has stopped, run:
cp -a ./nginx/sbin/nginx /usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx -tDo not extract the package directly into
/usr/local/, as this may overwrite the existing configuration. -
Start Nginx
After the configuration check succeeds, run:
systemctl start nginx -
Verify the Upgrade
/usr/local/nginx/sbin/nginx -vsystemctl status nginx --no-pagerConfirm that the version has changed and the service status is
active (running). Open HAP and check page access, login, and file uploads and downloads.
Version Rollback
If the new version fails to start or application access is affected, restore the executable from /usr/local/nginx.bak/.
-
Stop Nginx
systemctl stop nginx -
Restore the Previous Nginx Executable
After confirming that the service has stopped, run:
cp -a /usr/local/nginx.bak/sbin/nginx /usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx -t -
Start Nginx
After the configuration check succeeds, run:
systemctl start nginx -
Verify the Rollback
/usr/local/nginx/sbin/nginx -vsystemctl status nginx --no-pagerConfirm that the previous version is restored and the service status is
active (running). Check HAP access and application functions again.