Search code examples
phplaravelframeworksremote-server

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


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.


Solution

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