Using Plesk and you’re having trouble deploying your Symfony 4 application? We’re going to be setting up a Symfony 4 Application using Plesk step by step.
Requirements:
- PHP 7.1.3 or higher
- Plesk Onyx 17 Server
- A Symfony 4 Application
Step 1: Setting up your Subdomain:
For simplicity I’m going to be using a subdomain but feel free to use your main domain if you have access to change the Document root.
So, let’s create the subdomain “symfony” in my domain, click the “Domain” link on the left side:
Then click the button “Add Subdomain”
Make sure your “Document root” includes the “/public” folder of your Symfony application.
So your folder structure is going to look something like this:
1 2 3 4 5 6 7 8 9 10 11 |
. +-- symfony.victorcruz.me | +-- bin/ | +-- config/ | +-- public/ ** | +-- src/ | +-- var/ | +-- vendor/ | +-- config/ | +-- composer.json | +-- composer.lock |
Step 2: Add .htaccess file
The last step would be including the the following .htaccess file to be able to use the routes without using index.php as prefix. The file should placed in the public directory: /symfony.victorcruz.me/public/.htaccess
1 2 3 4 5 6 7 8 9 10 11 12 |
<IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L] </IfModule> <IfModule !mod_rewrite.c> <IfModule mod_alias.c> RedirectMatch 302 ^/$ /index.php/ </IfModule> </IfModule> |
Finally open the subdomain in your browser to and you should be good to go!!