2

I created a Symfony app following the documentation in https://symfony.com/doc/current/setup.html

And in my local server I use php bin/console server:run to server the app and everything was good.

But now that I want to deploy that app in a shared server that I use for small PHP apps (like corporate app without too many logic) I cannot make it work... In similar servers I have zend framework apps working correctly, but the symfony one is not working.

I notice that there isn't any index.php file in the root. It's a simple server with apache where I just drag the files through FTP (don't have SSH connection) but the server is not executing the php framework

Do i have to generate a build or something like that in order to mvoe the generated files to the server?

1

3 Answers 3

4

There is an index.php in the "public" directory, which should be the "root" for your public webserver path.

Please see this page for the details regarding the webserver configuration, including Apache:

https://symfony.com/doc/current/setup/web_server_configuration.html

Sign up to request clarification or add additional context in comments.

1 Comment

As per my understanding I have to change just the extra.public-dir in composer file... but then I run php bin/console server:run and I get the error [ERROR] The document root directory "/../public" does not exist. (because I change the name of the folder), but the change in the composer is not being considered. Should I need to run other command?
1

Well, finally it was much simpler solution that I was told. I just copy and pasted all the content of my project (including the public folder) in the public_html folder that was generated by my shared server.

Then create an .htaccess in the public_html with the following content:

RewriteEngine On
RewriteRule .* public/index.php

And that was all!

1 Comment

I'm not sure this is a good idea, since it will also redirect all assets (CSS, images, ...) to your front controller.
-1

Look, you can do this, but you shouldn't.

You are going to waste days on figuring out how to manage deployment, install dependencies, empty/warmup cache, and this is just for the most basic symfony application.

Stop it right now, save yourself the headache and buy a VPS.

I have given this advise many times, most of the time it fell on deaf ears. One time I asked a fellow developer this: Was the 40 hours you wasted on this worth it? You billed your client 40 hours for this, a suitable VPS would have only cost half (all in all), and would have spared you a ton of future headaches.

(Arne's post about the server config is technically the correct answer though)

EDIT: I'm not suggesting you should use the php server on a VPS. A VPS would still need apache / nginx.

2 Comments

So youu are telling me that for other PHP frameworks like zend, with drag and drop is enough, but with symfony I will need to spend a lot of time to make it work in a shared server?
In a way, yes. Modern PHP frameworks, like Symfony, Laravel and many less popular ones moved away from copy-paste deployment, and use tools like composer, cli scripts, deployment tools etc. to manage the application. You still can copy stuff over FTP and clear caches by deleting the files, but as your application grows, you will have more and more trouble with the old ways.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.