How to execute "php artisan migrate" and other Laravel commands in remote server?

11,018

You can ssh to the server and perform the command, you can add your servers public key to the remote server to do this without a password. I made a bash script with the following code which I can then execute manually via command line or from a program, lets say I call it myscript.sh with the following code

ssh [email protected] << EOF
cd /var/www/app/;
php artisan migrate --force; // force prevents artisan from asking for a yes/no on production
exit;
EOF

now I can write 'sh myscript.sh' and it will run migrations on the remote server.

Share:
11,018
Youssef Had
Author by

Youssef Had

Updated on June 04, 2022

Comments

  • Youssef Had
    Youssef Had almost 2 years

    I'm using Laravel 4.2 in remote server and I want to execute Laravel commands php artisan migrate but I don't know how.