我要评分
获取效率
正确性
完整性
易理解

Manual Packaging

Package source components according to the following instructions 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.
  • If Nginx is installed using an RPM package, it cannot be migrated by manually adding components. To migrate Nginx in this case, you can select the VM image migration method or manually migrate it.

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

  1. 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.

  2. 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
    
  3. 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.

    1
    ps -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
    
  4. 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.

    1
    vi Source_Nginx_startup_configuration_file
    

    For 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
    
  5. In the source_related directory, delete the repeatedly copied Nginx installation directory.

    Check whether the source Nginx installation directory exists in the source_related directory.

    1
    ll /home/nginx_mig_tmp/Source_Nginx_installation_directory/sbin/source_related/Absolute_path_to_the_source_Nginx_installation_directory
    

    If yes, delete it.

    1
    rm -rf /home/nginx_mig_tmp/Source_Nginx_installation_directory/sbin/source_related/Absolute_path_to_the_source_Nginx_installation_directory
    
  6. 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.
    1. Run the following command (nginx.tar.gz is used as an example):
      1
      tar cvf nginx.tar.gz /home/nginx_mig_tmp
      
    2. Obtain the source components in either of the following ways:
      • If you choose to upload the source component package, upload the TAR package on the DevKit page.
      • If you choose to obtain the source components from the node server, decompress the source component package. Replace the package name with the actual one.
        1. Log in to the tool through SSH and upload the compressed package to a user-defined directory on the node server.
        2. Go to the directory that stores the package.
          1
          cd User-defined_directory
          
        3. Decompress the source component package. Replace the example package name with the actual one.
          1
          tar xvf nginx.tar.gz
          
        4. After the decompression is complete, you can run the following command to delete the source component package.
          1
          rm -f nginx.tar.gz
          
        5. Set the path to the decompressed files as the source component path.
  7. After the packaging is complete, delete the /home/nginx_mig_tmp directory.