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.
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.
Step 3: In the Horizontal Scaling section, click on the PHP option.
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.
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.”
These steps ensure your Laravel application runs smoothly on the AccuWeb.Cloud environment.
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.
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.
Step 5: After the upload, a message will appear:
“Deploy to ROOT of Application Server: The process has been successfully finished.”
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.
Go to the Laravel environment and click on Change Environment Topology.
Select SSL, then click the Built-In SSL Off button to enable the free Let’s Encrypt SSL Certificate.
Once enabled, you’ll see a green outline in the Topology wizard. Click Apply to save the changes.
Refresh your webpage to check if the error is resolved.
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.
Step 2: In the Application Servers Configs window, go to the Favorites section and click on the conf option.
Step 3: Locate the httpd.conf file in the Conf folder, click on the gear icon and select Open.
Step 4: Scroll to the end of the httpd.conf file and find the DocumentRoot line.
Step 5: Update the DocumentRoot path to point to your Laravel application’s public folder.Â
For example:
DocumentRoot "/var/www/webroot/ROOT/public"
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.
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.
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.
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.
Step 4: Click Create to set up the database.
Step 5: Click on the Import tab in the upper-right corner.
Step 6: In the File to Import section, use the Upload a file option to upload the .sql file from your local system.
Step 7: Click the Import button to start the process.
Step 8: After the import is complete, you will see a message like:
“Import has been successfully finished, 128 queries executed.”
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.
Step 2: Navigate to the folder where your Laravel files are stored. For example, /var/www/webroot/ROOT.
Step 3: Find the .env file and click on the gear icon. Then, select Open to edit the file.
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
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.
2. Submit the form to check if the registration works.
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.