How to install a PHP Symfony application on cPanel

Symfony is a Open Source MVC framework written in PHP that allows you to quickly and easily build powerful websites. This article shows how to install and configure a Symfony demo app on a Linux shared web hosting account that uses cPanel. This demo application uses a SQLite database.

 
Note that you can install a newer version of SQLite if needed:

How to install latest SQLite version on cPanel

 

1. Log into your cPanel account

 

2. Configure the Symfony app

a) Use Terminal or connect with SSH

advanced_title_en.png
terminal_en.png

b) Create a new directory
$ mkdir ~/demo_symfony_app
c) Download and unzip the demo project
$ cd ~/demo_symfony_app
$ wget https://demo.vtinyhosting.com/vtiny-symfony-demo.zip
$ unzip vtiny-symfony-demo.zip
$ rm vtiny-symfony-demo.zip
d) Install the "packages" (a new directory will be created: "vendor")
$ composer install -d ~/demo_symfony_app
e) Generate the "htaccess" file for Apache
$ composer update symfony/flex --no-plugins --no-scripts
$ composer require symfony/apache-pack -d ~/demo_symfony_app

Answer "y" to the question asked.

f) Move the contents of the "public" directory

The default target is "public_html". Here for the demo, we are using a subdomain directory ("public_symfony").

$ mv ~/demo_symfony_app/public/* ~/public_symfony
$ mv ~/demo_symfony_app/public/.htaccess ~/public_symfony
g) Modify the content of the "index.php" file
$ nano ~/public_symfony/index.php

Replace :

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

By :

require_once dirname(__DIR__).'/demo_symfony_app/vendor/autoload_runtime.php';

To save the file: Ctrl+O and Enter
To exist the Nano editor: Ctrl+X

 

3. Test the site

In your browser, enter the url of your application (section 2.f):
https://[your_url_application]

 

Vtiny Hosting demo link :
https://symfony.demo.vtinyhosting.com/

  • cPanel, Developer, PHP, Symfony
  • 587 Users Found This Useful
Was this answer helpful?

Related Articles

How to install latest SQLite version on cPanel

Since all versions of SQLite can be easily installed locally on your shared hosting accounts, it...

How to install a Python Django application on cPanel

Django is a Python-based framework that lets you build powerful websites quickly and easily. This...

Powered by WHMCompleteSolution