Symfony is an open-source PHP system with a reputation as a suitable framework to kick-start any project, regardless of its specifications. As a set of reusable components, its adaptability, design, and highly optimized structure and execution make it a top choice for building a complex enterprise application.
Linode is one of the 5 cloud infrastructure providers available on the Cloudways platform, nestled between Vultr, DigitalOcean, AWS, and GCE. Cloudways users now have another great option to host their Symfony version 4.x & upcoming applications. Previously, I ran a series of articles on Symfony, covering its technical use cases and how-to’s. Symfony 4 is the latest in this long line of this tradition, packed with excellent features (such as Symfony Flex) that will transform web development.
Linode’s stability and developer-friendly features have long made it a favorite in Symfony communities. Cloudways PHP MySQL hosting adds another layer of optimization through the managed ThunderStack on Linode servers. In this article, I will demonstrate the deployment of a Symfony application on a Linode server.
- Cloudways ThunderStack
- Deploying Symfony Applications on Linode Server
- Deploy Using GitLab on Cloudways Platform
- Pre-Installed Composer & Git
For blazing fast speeds and glitch-free performance, Cloudways has built a custom PHP stack, known as ThunderStack. This stack combines advanced technologies to offer maximum uptime and page load speed to all PHP applications. Here are the technologies Cloudways integrates to make ThunderStruck.
As you can see, ThunderStack comprises a mix of static and dynamic caches with two web servers: Nginx and Apache. This combination ensures the ultimate experience for the users and visitors of your application. The stack also offers top database tools MySQL and MariaDB.
Cloudways also employs PHP-FPM in its stack, an advanced PHP cache mechanism that boosts the performance of the server.
Nothing as Easy as Deploying Symfony Apps on Cloud
With Cloudways, you can have your Symfony apps up and running on managed cloud servers in just a few minutes.
Deploying Symfony Applications on Linode Server
You will see the power of the Cloudways Platform from the first step! Signing up for your account at Cloudways takes only a few minutes!
To set up a PHP 8 server on Linode at Cloudways, simply sign up for your Cloudways account, and then login.
Next, at the server launch page, select Custom PHP App as your application & Linode as your infrastructure provider. Next, identify your server resource needs along with other required details.
And you’re done! Your Linode server will now be deployed. By default you will get PHP 8.0 on the server. However, you can upgrade or downgrade to any of the PHP versions, that is, to versions 5.6 to PHP 8.
Launch the SSH Terminal
Click on to the “Server Management tab” to launch “SSH Terminal” that is located in the “Master Credentials”. Here you can find your login credentials for the SSH terminal.
Login to SSH with these Master Credentials.
Empty your public_html directory
Empty your public_html directory by deleting all files in it. To remove all files, move to your public_html folder and delete all files using `rm -Rf *` command.
Install Symfony Using Composer:
Moving on, use the following command to install Symfony through composer.
composer create-project symfony/website-skeleton myproject
After providing your database information, the Symfony installation will soon be complete.
You can access the Symfony welcome page by adding /myproject/public/ to the default application URL. If you see the welcome page, everything has been configured successfully.
Open any web browser and access the welcome page of Symfony by entering
That’s it: your latest version of Symfony is ready to use.
Deploy Using GitLab on Cloudways Platform
You can deploy your PHP Application on Cloudways platform from GitLab by following these simple executional steps.
Step 1: Generate the SSH Key
Sign in to your Cloudways account, access the server where you have to deploy the application, and go to the Applications Settings,
Deploying Symfony Application on Linode From GitLab
You likely have your PHP application on GitHub. No problem, because you could easily deploy it on the Cloudways Platform. The Platform has a simple system for direct deployment of your application from Git repositories.
To deploy the application from a Git repo, first, in the Platform dashboard, click the ‘Applications’ tab from the top menu bar. Select your application from the list that pops down. You will now need a mechanism to generate and download the SSH keys that are the critical-authentication aspect of the process.
You Might Also Like: Create Token Based API Authentication in Symfony
Step 2: Upload SSH Key To GitLab Repository
To do this, click on the ‘Deployment via Git’ button in the ‘Application Management’ area, and then click the ‘Generate SSH Keys’ button to generate your unique SSH key. To download these keys, simply click on ‘Download SSH Keys’.
To allow Cloudways to access your application on the Git repository, upload the ‘SSH Public Key’ (that you have just downloaded in the previous step) to the GitLab.
For this, login to your GitHub account, go to the desired repository, and into the ‘Settings’ tab. Here, locate the ‘Add Deploy Key’ button and use it to add the SSH Public Key. You can do this by opening the file downloaded in the previous step and pasting its content into the space provided by GitHub. Click on the ‘Add Key’ button to finalize the input of the SSH key.
Step 3: Copy the SSH Address Of Repository
Move to the repository which you would like to clone on the server. Click on the Clone option which drops down and shows two choices: Clone with SSH or Clone with HTTPS. Copy the URL beneath the Clone with SSH. Note: The option to Clone with HTTPS isn’t supported by the Cloudways Platform.
PHP-FPM, Varnish & Cron Settings
Cloudways provides a custom UI panel to set and maintain PHP-FPM and Varnish settings. Although the default configuration is already in place, you could easily change all the settings to suit your own particular development related requirements. In Varnish settings, you can define a URL that is to be excluded from caching. You can also set permissions in this panel.
Cron jobs are a very commonly used component of the PHP application development process. On Cloudways Platform, you could easily set up cron jobs in just a few clicks. Just declare the PHP script URL and the time when the script will run.
Step 4: Deploy the Application Code from the Repository
Move back to the Cloudways Application Settings > Deployment Via Git, and paste the SSH address of the repository you have got replicated.
Click Authenticate to let Cloudways authenticate the SSH address.
After authentication, select the branch of your GitLab repository you wish to deploy from. Here, I am utilizing the Master branch. Next, type the deployment way. Conclude the arrangement with a /. In case you leave this field null, the code will be deployed to the public_html/ folder by default.
Finally, click Start Deployment to deploy your code.
Upon successful GitLab deployment of your application, you’ll get a green-colored pop-up message “Git cloned”.
Pre-Installed Composer & Git
PHP development requires working with external libraries and packages. Say you are working with Laravel and you need to install an external package. Since Composer has become the standard way of installing packages, it comes preinstalled on the Cloudways platform. Just launch the application and start using Composer in your project.
Similarly, if you are familiar with Git and maintain your project on GitHub or BitBucket, you don’t need to worry about Git installation. Git also comes pre-configured on Cloudways. You can start running commands right after application launch.
It is that simple to set up Managed Linode servers to boost your PHP application on Cloudways. As you can see, everything can be done with a click, whether it’s PHP services, application settings or SSL installations. Cloudways eases the hectic process of managing server settings and deploying your PHP apps, so you can dedicate your time and focus on your business.
If you have any questions, ask away in the comments.
Inshal is a Content Marketer at Cloudways. With background in computer science, skill of content and a whole lot of creativity, he helps business reach the sky and go beyond through content that speaks the language of their customers. Apart from work, you will see him mostly in some online games or on a football field.