When managing a hosting account, you may need to quickly compress or extract files directly on the server. This can significantly speed up deployments and reduce the need for FTP transfers. Below are two common methods: using SSH or using a PHP script.
Table of Contents
Method 1 – Using SSH
After enabling SSH access and logging into your hosting account, you can manage archives directly from the command line.
Create a ZIP archive
To compress a folder into a ZIP file, use the following command:
zip -r archive_name.zip folder_name
This will create a compressed archive containing all files and subfolders inside the specified directory.
Extract a ZIP file in the same directory
To unpack an archive in its current location, use:
unzip archive_name.zip
Extract a ZIP file to a specific folder
If you want to extract files to a different directory, specify the destination path:
unzip archive_name.zip -d destination_folder
This is useful when deploying applications or restoring backups into specific locations.
Method 2 – Using a PHP Script
If SSH access is not available, you can use a PHP-based solution to manage ZIP archives directly from your browser.
Extracting ZIP files
For large archives containing hundreds or thousands of files, uploading them uncompressed via FTP can be inefficient. Instead, you can use a script such as Unzipper.
To use it:
- Upload
unzipper.phpto your domain’s root directory (for example,public_html) - Upload the
.ziparchive you want to extract to the same directory - Run the script via your browser
The script will extract all files directly on the server, saving time and bandwidth.
Creating ZIP archives
Some PHP tools also allow you to create ZIP archives directly on the server. This can be useful when backing up folders already stored on your hosting account.
Typically, you:
- Select the folder you want to compress
- Execute the archive creation function
- Download or move the resulting
.zipfile as needed
Additional Notes
If you are working with FTP, you may also need a proper FTP client configuration to upload or download files efficiently.
For reference, see your hosting provider’s guide on connecting via FTP to manage files more easily.
Conclusion
Both SSH and PHP-based tools provide efficient ways to manage file archives on a server. SSH offers faster and more flexible control for advanced users, while PHP scripts are useful when SSH access is not available.