Migrating Symfony from cPanel to Cloudways Platform
In the previous installment, I touched upon the topic of bundle management in Symfony 3.1
Symfony is a very popular MVC framework for banking and ecommerce applications. The strength of the framework is its versatile application as both a core PHP and web development platform. This diversity of application is made possible by a wide range of reusable components that directly and indirectly integrate with popular frameworks and libraries. The latest stable version of Symfony version 3.1 with version 3.2 being released in beta state. Recently, Symfony has been downloaded 500 million times.
In this tutorial, I will explain how you could migrate Symfony sites from cPanel powered shared hosting to managed cloud hosting offered by Cloudways. Migrating Symfony to a different host is easy enough. The process of migrating Symfony Websites to Cloudways starts with signing up for an account on Cloudways. Next, follow these steps for migrating the website.
Step 1: Backup the Website
Login to the cPanel hosting account.
Next, create a zip archive of all the files inside the Symfony folder.
Once the compression process finishes, login to the database manager (PHPMyAdmin in many cases) and export the database(s) to the local system.
Add the database to the folder that contains the Symfony zip archive. This way, all relevant data could be downloaded imported to Cloudways through SSH terminal.
You are now done with your old hosting.
Step 2: Launch Cloudways PHP Stack Application
Login to Cloudways Platform and launch a PHP stack application. In case of problems, refer to the following GIF.
Step 3: Start the Migration Process
Now launch SSH terminal (or download PUTTY) and login with your server’s Master Credentials.
Now, to access public_html folder of the application, enter the following command in the terminal.
cd applications/<your application name>/public_html/
where <your application name> can be found on the Cloudways platform by clicking on the newly added PHP application and then going to the Application Setting tab.
Now, inside the public_html, use the following command to remove all the files in the folder.
rm -rf *
The folder is now empty. The next step is to download the zip archive from the shared hosting Now the folder is empty let’s now download the zip that we have created in your shared hosting through the domain. For example, if your domain is abc.com then the download URL for the zip archive is abc.com/Smyfony.zip.
In the terminal, type the following command to download the zip archive in the in the public_html folder.
Once done, unzip the file.
Next, edit Symfony database parameters from SSH terminal using the following command
Press i to start editing the file. Copy the database credentials from the Application Access Details and replace the existing credentials. Once done, press Esc and enter :wq to save and exit the file.
Next Import the database to Cloudways. For this, first download the database to public_html using the following command.
After the download finishes, type the following command to import the database into Cloudways.
mysql -u <username> -p <databasename> < database.sql
<databasename> can be found in Application Access details. The command will ask for the password.
Once the processing finishes, you should visit the staging URL of the PHP app to check out your Symfony based website/app.
In this tutorial, I discussed how you can migrate a Symfony site to Cloudways in three simple steps. Here is a short introduction and list of major topics in this Symfony 3.1 series. If you have a question or would like to add to the discussion, please leave a comment below.
Originally published at www.cloudways.com on November 15, 2016.