How to Migrate a Laravel Site to AccuWeb.Cloud?

How to Migrate a Laravel Site to AccuWeb.Cloud?

Laravel is a free tool built with PHP that helps developers create web applications. It follows the Model-View-Controller (MVC) design, making it easier to organize code. Laravel has useful features like a database manager (Eloquent ORM), templates for designing pages, built-in libraries, and support for managing sessions and cache storage.

While many PHP tools exist, some can make the application’s code hard to understand and document.

This guide will show you how to move a Laravel application to the AccuWeb.Cloud dashboard.

Requirements

Before starting, make sure you have installed the following on your AccuWeb.Cloud dashboard:

  • The Laravel application from the Marketplace
  • A MySQL database in the same environment as Laravel

Steps to Move Your Laravel Website to the AccuWeb.Cloud Environment

You can follow the steps below to transfer your Laravel website from another host to your AccuWeb.Cloud environment.

Choose the Right PHP Version for Your Laravel Application

Make sure to select the same PHP version used by your existing Laravel application on your previous hosting provider. Choosing a different PHP version can cause errors because of incompatible dependencies.

Note: If you install Laravel from the Marketplace, it will automatically use the latest PHP version that is compatible with Laravel.

Follow these steps to update the PHP version of your Laravel application:

Step 1: Log in to your AccuWeb.Cloud dashboard.

Step 2: Choose the environment where you installed the Laravel application and click on the Change Environment Topology option.

Change Environment Topology

Step 3: In the Horizontal Scaling section, click on the PHP option.

Horizontal Scaling

Step 4: Select the PHP version used by your previous hosting provider or the one compatible with your Laravel application. For example, if your application was built with PHP 8.1, select PHP 8.1. The Laravel version will automatically adjust based on your PHP selection.

PHP selection

Step 5: Click the Redeploy button to install the selected PHP version and the compatible Laravel version.

Step 6: Once the redeployment is complete, you will see a confirmation message, such as:
“Redeploy Apache container(s) of env-9708245 to the 2.4.62-php-8.1.30-almalinux-9 tag successfully finished.”

Redeploy

These steps ensure your Laravel application runs smoothly on the AccuWeb.Cloud environment.

Save $100 in the next
5:00 minutes?

Register Here

Upload Your Laravel Backup File to the AccuWeb.Cloud Environment

To upload your website backup file to the AccuWeb.Cloud environment, use the Deployment method. Follow these steps to upload or deploy the backup file:

Step 1: Choose the environment where you installed the Laravel application.

Step 2: Navigate to the Application Servers section and click on Deployments.

Step 3: Select the method to deploy your application. In this example, choose Deploy Archive.

Deploy Archive

Step 4: Go to the Local file section in the Deploy to Application Server window.

  • Use the Browse option to upload the zip file of your Laravel application from your local system.
  • Leave the Path field unchanged and click Deploy to upload the file.

Application Server window

Step 5: After the upload, a message will appear:
“Deploy to ROOT of Application Server: The process has been successfully finished.”

Uploaded message

Step 6: Click Open in Browser to run your application.

If you see a “503 SSL Service Unavailable” error, it means your website doesn’t have an SSL certificate.

503 SSL Service Unavailable

Go to the Laravel environment and click on Change Environment Topology.

Change Environment Topology

Select SSL, then click the Built-In SSL Off button to enable the free Let’s Encrypt SSL Certificate.

Built-In SSL

Save $100 in the next
5:00 minutes?

Register Here

Once enabled, you’ll see a green outline in the Topology wizard. Click Apply to save the changes.

Topology wizard

Refresh your webpage to check if the error is resolved.

403 Forbidden

If the error changes to “403 Forbidden,” follow additional steps to resolve it.

Edit the httpd.conf File to Fix the 403 Forbidden Error

Now, you need to edit the httpd.conf file to point to the Laravel public folder because the Laravel application reads the file stored or present in the public folder by default.

Follow these steps to update the httpd.conf file:

Step 1: Go to Application Servers and click on the Config option.

Application Servers

Step 2: In the Application Servers Configs window, go to the Favorites section and click on the conf option.

Application Servers Configs

Step 3: Locate the httpd.conf file in the Conf folder, click on the gear icon and select Open.

Conf folder

Step 4: Scroll to the end of the httpd.conf file and find the DocumentRoot line.

DocumentRoot line

Save $100 in the next
5:00 minutes?

Register Here

Step 5: Update the DocumentRoot path to point to your Laravel application’s public folder. 

For example:

DocumentRoot "/var/www/webroot/ROOT/public"

Laravel application's public folder

Step 6: After that, click the Save button to apply your changes.

Step 7: To apply the changes, restart the Apache service. Go to Application Server and click on Restart Nodes.

Restart Nodes

Step 8: Reload the webpage where you saw the 403 Forbidden error.

After completing these steps, the error will be resolved, and your website’s homepage should load. For example, if you are using Laravel, you’ll see its default home page.

Laravel home page

Restore Your Database Backup

You can restore the database in AccuWeb.Cloud uses a web-based tool (phpMyAdmin) or the command line (Web SSH). Here, we’ll use phpMyAdmin as it’s easier.

Step 1: Access your MySQL database through phpMyAdmin.

Step 2: Click on Databases in the upper-left corner.

MySQL database

Save $100 in the next
5:00 minutes?

Register Here

Step 3: In the Create Database section, enter the database name in the Database name field. Use the same database name as your previous hosting.

Create Database

Note: If you use a new name, update the .env file of your Laravel application to match.

Step 4: Click Create to set up the database.

Step 5: Click on the Import tab in the upper-right corner.

Import tab

Step 6: In the File to Import section, use the Upload a file option to upload the .sql file from your local system.

File to Import

Step 7: Click the Import button to start the process.

Click the Import button

Step 8: After the import is complete, you will see a message like:
“Import has been successfully finished, 128 queries executed.”

Restored Database

Your database is now restored and ready to use!

Update the .env File for Database Connection

To connect your Laravel application to the database, you need to update the database details in the .env file. Follow these steps to complete it through AccuWeb.Cloud dashboard:

Step 1: Go to Application Server and click on the Config option.

Save $100 in the next
5:00 minutes?

Register Here

Step 2: Navigate to the folder where your Laravel files are stored. For example, /var/www/webroot/ROOT.

Laravel stored files

Step 3: Find the .env file and click on the gear icon. Then, select Open to edit the file.

Gear icon

Step 4: Look for the DB_CONNECTION section in the file and update the following details:

DB_CONNECTION=mysql     // Type of database (e.g., MySQL)
DB_HOST=127.0.0.1       // Database server hostname
DB_PORT=3306            // Port number used by the database
DB_DATABASE=trainee2    // Name of your database
DB_USERNAME=trainee2    // Database username
DB_PASSWORD='YourPassword'  // Database user password

Update details

Step 5: Click the Save button to apply the updates to the .env file.

Your Laravel application is now connected to the database!

Check Your Website Pages

To confirm everything is working, test different pages on your website, like the Login, Register, and Contact Us pages.

For example, let’s test the Register page:

1. Open the Register page and fill in some demo details.

Demo details

2. Submit the form to check if the registration works.

Checking for registration

If the registration is successful, the Laravel application will be successfully migrated to AccuWeb.Cloud environment!

Conclusion:

Migrating a Laravel application to AccuWeb.Cloud is easy. Simply set up the database and environment variables for the server, then upload your application files using FTP or Git. After deployment, adjust file permissions, run migrations, and clear caches with Laravel Artisan commands. Finally, test the app to ensure it works correctly. AccuWeb.Cloud’s user-friendly interface and reliable hosting provide great performance and scalability for your Laravel projects.

Save $100 in the next
5:00 minutes?

Register Here