๐๐ฒ๐ฝ๐น๐ผ๐ท๐ถ๐ป๐ด ๐ฆ๐ถ๐บ๐ฝ๐น๐ฒ ๐ฆ๐๐บ๐ณ๐ผ๐ป๐ถ๐ฒ ๐ด ๐ง๐ผ ๐ฐ๐ฃ๐ฎ๐ป๐ฒ๐น: ๐ ๐ฆ๐๐ฒ๐ฝ-๐๐-๐ฆ๐๐ฒ๐ฝ ๐๐๐ถ๐ฑ๐ฒ
You want to deploy your Symfony app to a shared hosting environment with cPanel and no SSH access. Here's how you can do it:
- Double-check your code for any issues
- Configure your environment variables
- Install and update your vendors
- Clear your Symfony cache
- Install the symfony/apache-pack
- Update your composer.json file
- Build your assets
- Update your Kernel.php file
- Upload your project to cPanel
To start, double-check your code. Make sure everything is working as expected. You can use the dotenv:dump command to configure your environment variables. Run the command: APP_ENV=prod APP_DEBUG=0 php bin/console dotenv:dump
Next, install and update your vendors using: composer install --no-dev --optimize-autoloader. Then, clear your Symfony cache: APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear
You may need to install the symfony/apache-pack using: composer require symfony/apache-pack. This creates the .htaccess configuration required for Symfony routing.
Update your composer.json file to override the public directory: "extra": {public-dir: "public_html" }
Build your assets using: symfony console tailwind:build and symfony console asset-map:compile
Update your Kernel.php file to define the project_dir:
public function getProjectDir(): string
{
return \dirname(__DIR__);
}
Finally, upload the necessary files to cPanel:
- bin/
- config/
- migrations/
- public_html/
- src/
- templates/
- translations/
- vendor/
- var/
- .env.local.php
Exclude unnecessary files and folders. Zip the selected files and upload them to cPanel.
Source: https://dev.to/ashrafchitambaa/deploying-symfony-8-to-cpanel-step-by-step-guide-4k5o