How to migrate an existing Laravel installation

This article describes how to migrate an existing Laravel site to your A2 Hosting account. You may need to do this, for example, if you developed a Laravel site on another computer, or want to migrate an existing Laravel site from another hosting provider to A2 Hosting.

Although A2 Hosting servers are compatible with a wide variety of software applications, we cannot provide troubleshooting assistance for application-specific issues.

Migrating Laravel

To migrate a Laravel site to your hosting account, follow these steps:

  1. Upload the Laravel project files to your account. You can use the cPanel File Manager or SFTP to do this.
  2. Log in to your account using SSH.
  3. To enable running Artisan by simply typing artisan at the command prompt, type the following commands. Replace username with your account username, and project with your project name:
    echo 'alias artisan="php /home/username/project/artisan"' >> ~/.bashrc
    source ~/.bashrc
    
    Artisan is the command-line interface to Laravel. When you create a Laravel project, Artisan is installed automatically in the project directory. For more information about Artisan, please visit http://laravel.com/docs/artisan.
  4. To make the Laravel project files accessible to web visitors, you must copy all of the files in the /home/username/project/public directory to the public_html directory. To do this, type the following command, replacing project with the project name:
     cp -r ~/project/public/* ~/public_html
    
    Alternatively, if you want to use a subdirectory beneath the public_html directory, copy the public files there instead. For example, the following command copies all of the public files to the laravel subdirectory:
     cp -r ~/project/public/* ~/public_html/laravel
    
    In this case, the Laravel site would be accessible at http://www.example.com/laravel, where example.com represents your domain name.
  5. In the public_html directory, open the index.php file in your preferred text editor, and then modify it as follows:
    • Locate the following line:
      require __DIR__.'/../vendor/autoload.php';
      Modify the path to include the directory where Laravel is installed. For example, if Laravel is in the project directory, you would change the line as follows:
      require __DIR__.'/../project/vendor/autoload.php'
    • Locate the following line:
      require __DIR__.'/../bootstrap/app.php';
      Modify the path to include the directory where Laravel is installed. For example, if Laravel is in the project directory, you would change the line as follows:
      require __DIR__.'/../project/bootstrap/app.php'
  6. Save your changes to the index.php file.
  7. In your web browser, go to http://www.example.com, where example.com represents your domain name. You should see the Laravel welcome page.
    Make sure you repeat steps 4 to 6 if you modify any of the public site files in the project directory.

More Information

For more information about Laravel, please visit https://laravel.com.

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.