# Migrating an existing Laravel installation

> Move a Laravel app from your computer or another host to your hosting account and configure it to run correctly.

Source: https://helpcenter.ruachost.com/apps/manual-installations/migrating-an-existing-laravel-installation/

If you’ve developed a **Laravel** application locally or on another hosting provider, you can migrate it to your **ruachost.com** hosting account. This process ensures your project files and configurations are properly set up to run on your new server.

## Why Migrate Laravel?

- Move projects from local development to production.
- Transfer applications between hosting providers.
- Maintain consistency across environments.

## Steps to Migrate Laravel

1. **Upload Laravel Project Files.**

   - Use **cPanel File Manager** or **SFTP** to upload your Laravel project files to your hosting account.
   - Place them in your home directory (e.g., `/home/username/project`).
2. **Log in via SSH.**

   - Connect to your hosting account using SSH.
   - To enable running Artisan easily, add an alias:

     ```bash
     echo 'alias artisan="php /home/username/project/artisan"' >> ~/.bashrc
     source ~/.bashrc
     ```
3. **Make Public Files Accessible.**

   - Copy all files from the Laravel `public` directory to your `public_html` folder:

     ```bash
     cp -r ~/project/public/* ~/public_html
     ```
   - Alternatively, copy to a subdirectory (e.g., `public_html/laravel`):

     ```bash
     cp -r ~/project/public/* ~/public_html/laravel
     ```

     In this case, your site will be accessible at `http://example.com/laravel`.
4. **Update index.php  Paths.**

   - Open `public_html/index.php` in a text editor.
   - Update the following lines to point to your Laravel project directory:

     ```
     require __DIR__.'/../project/vendor/autoload.php';
     require __DIR__.'/../project/bootstrap/app.php';
     ```
5. **Configure Environment File.**

   - Edit `.env` in your Laravel project directory.
   - Update database, mail, and app settings to match your **ruachost.com** environment.
6. **Run Migrations and Seeders.**

   - From SSH, run:

     ```
     artisan migrate
     artisan db:seed
     ```
   - This will set up your database schema and seed initial data.
7. **Verify Installation.**

   - In your browser, go to `http://example.com`.
   - You should see your Laravel application running.

> **Note:**
- Laravel migration is supported on all **ruachost.com** accounts.
- Always use strong database and admin credentials.
- Repeat steps 3–4 if you modify any public site files in the project directory.
- Consider enabling automatic backups for added protection.
