← Back to articles

Cloud Operations: Deploying on a VPS

Published Apr 4, 2026

Deploying a Laravel application to Hostinger shared hosting requires a few specific adjustments, as shared environments differ from local development setups.

Deploying Your Laravel Application

  1. Prepare Files: Upload your project files (excluding the vendor folder) to your domain’s root directory (e.g., /domains/yourdomain.com/public_html).

  2. Move Public Content: Laravel expects requests to hit the public/ directory, but web servers typically serve from public_html/.

    • Move the contents of your public/ directory into public_html/.

    • Update the index.php file in public_html/ to point to the correct paths for your autoload.php and bootstrap/app.php files (usually by updating the ../ path references).

  3. Environment Configuration: Copy .env.example to .env and update your database credentials, APP_URL, and other necessary variables.

  4. Dependencies: Use the terminal/SSH to navigate to your project directory and run: composer install --no-dev --optimize-autoloader


Running Artisan Commands with a Specific PHP Version

When working in a shared hosting environment, simply running php artisan may use the server's default PHP version, which might not match the version required by your application.

To force a specific version for Artisan commands, you must use the absolute path to the desired PHP binary.

  1. Find the Binary Path: You can usually find the available paths by checking the PHP configuration in hPanel, or by running ls /usr/local/bin/php* in your SSH terminal. You will see paths like /usr/local/bin/ea-php82 or /usr/local/bin/lsphp83.

  2. Execute the Command: Use the full path instead of the php alias:

    Bash

    /opt/cloudlinux/alt-php84/root/usr/bin/php artisan migrate 
    

Note: If you are unsure which binary to use, check your current PHP version on the command line by typing php -v. If it is incorrect, use the path identified in Step 1 to run your commands.