Customer SSH - Useful Commands
1. Entering the Customer's Application Container
To access a customer's website container, you have two options:
- Via SSH Key: Add your SSH key through "Developer Tools" in the UI when viewing the customer's website. Then, SSH into the server as the specified user (e.g.,
username@server_ip
). - Via Root Access: Once logged in, type the following command to switch to the customer’s environment:
su - customer_username
Either method will give you access to the customer’s containerized PHP environment, allowing you to interact with their file structure, binaries, and PHP processes.
2. Running PHP Scripts
-
PHP Binary: The PHP binary is located at
/usr/bin/php
. This corresponds to the version selected by the customer in the "Developer Tools" section of their dashboard. -
Execute PHP Script: To run a PHP script, use the command:
php script.php
This will display the script's output.
-
Debugging with strace: To view the system calls PHP is making (such as reading files or connecting to an IP), use:
strace php script.php
-
Piping Output:
- To save the script output to a file:
php script.php > script.log
- To save both output and errors:
php script.php > script.log 2>&1
- To save the script output to a file:
3. Useful Commands for Managing the Environment
- Composer: To manage PHP dependencies, use:
/usr/bin/composer
- WP CLI: For WordPress tasks, use:
/usr/bin/wp-cli
- Monitor Processes: Use
top
to view processes running in the container, including CPU and memory usage:/usr/bin/top
- File Management:
- Remove a file:
/usr/bin/rm
- Create a new directory:
/usr/bin/mkdir
- Change file or directory permissions:
/usr/bin/chmod
- Remove a file:
4. Copying Files
You can use SSH and rsync for secure file transfers, avoiding the need for root access.
5. Managing Cron Jobs
Cron jobs cannot be edited directly from the customer's SSH environment. Use the control panel UI under "Developer Tools" to manage cron jobs.