Manual Packaging
Package source components following the instructions below to prevent data, configuration, and log files outside the installation package from being lost.
- This script supports only Nginx that is compiled from the source code with its binary file stored in the Nginx_installation_path/sbin directory.
- The tool cannot automatically migrate Nginx installed using an RPM package. Perform a manual migration instead.
Files to Be Migrated
- Source Nginx installation directory (containing conf, html, logs, and sbin)
- Paths specified by compilation parameters during Nginx compilation
- Nginx startup configuration file and the configuration file specified by nginx -c
- Other files and directories referenced in the configuration files and static files
Procedure
- Create a source_related directory under the sbin directory to store static files and other configuration files and directories outside the installation directory.
1 2 3 4
mkdir -p /home/nginx_mig_tmp cp -rp Absolute_path_to_the_source_Nginx_installation_directory /home/nginx_mig_tmp cd /home/nginx_mig_tmp/Source_Nginx_installation_directory/sbin mkdir source_related
For example, if the Nginx installation directory is /opt/portadv/tools/nginx-install, the absolute path to the source Nginx installation directory is /opt/portadv/tools/nginx-install, and the source Nginx installation directory is nginx-install.
- Check the dependency files specified by compilation options and copy the files to be migrated to the source_related directory according to the original directory structure.
If only the prefix path is specified during Nginx compilation, skip this step.
Check the compilation options.
1 2
cd Source_Nginx_installation_directory/sbin ./nginx -V
For example, if --error-log-path=/var/log/nginx/error.log is specified, run the following commands to copy the directory. The same applies to other compilation options.
1 2
mkdir -p /home/nginx_mig_tmp/Source_Nginx_installation_directory/sbin/source_related/var/log/nginx cp -p /var/log/nginx/error.log /home/nginx_mig_tmp/Source_Nginx_installation_directory/sbin/source_related/var/log/nginx
- Check the startup configuration file of the source Nginx and copy the file to the source_related directory according to the original directory structure.
You can skip this step if no configuration file path is specified for starting the source Nginx binary to be migrated.
1ps -ef | grep nginx
For example, if "nginx: master process {Source Nginx binary} -c /home/nginx_confs/nginx.conf" is displayed in the output of the ps -ef command, run the following commands to copy the file:
1 2
mkdir -p /home/nginx_mig_tmp/Source_Nginx_installation_directory/sbin/source_related/home/nginx_confs cp -p /home/nginx_confs/nginx.conf /home/nginx_mig_tmp/Source_Nginx_installation_directory/sbin/source_related/home/nginx_confs
- Check the dependency files and directories referenced in the source Nginx startup configuration file and copy the required ones to the source_related directory according to the original directory structure.
You can skip this step if all the referenced files and directories are in the source Nginx installation directory or the configuration file does not contain the following keywords: include, ssl_certificate, ssl_certificate_key, ssl_dhparam, error_log, access_log, root, alias, client_body_temp_path, fastcgi_temp_path, proxy_temp_path, proxy_cache_path, scgi_temp_path, and uwsgi_temp_path.
1vi Source_Nginx_startup_configuration_fileFor example, in the nginx.conf file, the root keyword specifies that the referenced HTML directory is /root/nginx/html. Run the following commands to copy the directory. The same applies to other files and directories.
1 2
mkdir -p /home/nginx_mig_tmp/Source_Nginx_installation_directory/root/nginx cp -rp /root/nginx/html /home/nginx_mig_tmp/Source_Nginx_installation_directory/sbin/source_related/root/nginx
- In the source_related directory, delete the repeatedly copied Nginx installation directory.
Check whether the source Nginx installation directory exists.
1ll /home/nginx_mig_tmp/Source_Nginx_installation_directory/sbin/source_related/Absolute_path_to_the_source_Nginx_installation_directoryIf yes, delete it.
1rm -rf /home/nginx_mig_tmp/Source_Nginx_installation_directory/sbin/source_related/Absolute_path_to_the_source_Nginx_installation_directory
- Compress the installation directory of the source components to be scanned into a package, for example, a tar.gz package. Replace the example package name with the actual one.
- Run the following command (nginx.tar.gz is used as an example):
tar cvf nginx.tar.gz /home/nginx_mig_tmp
- Obtain the source components using either of the following methods:
- If you select the Upload source component package option, return to the Add Component Information tab, and click Upload next to Upload source component package to upload the source component package.
- If you select the Obtain from node server option, run the following command to decompress the source component package.
- Log in to the tool through SSH and upload the package to the user-defined directory on Target Node.
- Go to the directory that stores the package.
1cd User-defined_directory
- Decompress the source component package.
tar xvf nginx.tar.gz
- After the decompression is complete, you can run the following command to delete the source component package.
rm -f nginx.tar.gz
- Set the path to the decompressed file as the source component path.
- Run the following command (nginx.tar.gz is used as an example):
- After the packaging is complete, delete the /home/nginx_mig_tmp directory.