Score:0

Error 500: Internal server error deploying Symfony 6 application on shared hosting (Apache)

eg flag

I have successfully deployed my application to a remote host using Deployer.

I'm on shared hosting and I don't have access to the Apache configuration.

The application is deployed in a directory created for an Add-on domain, that is, it is not in the main domain. This folder is into: home/serverid/myrootadon

When I try to navigate to the domain in which I have installed the app: https://example.com I get:

Error 500 - Internal Server Error

An error was encountered while processing your request. Typically this is a temporary condition. Please contact the web site owner for further assistance.

I don't understand what causes this error. I've tried looking in the error logs, but can't find anything.

In the root folder there is an error_log file only with this:

[01-Jun-2023 15:23:46 UTC] 2023-06-01T15:23:46+00:00 [info] User Deprecated: The "Monolog\Logger" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Bridge\Monolog\Logger".

In the var/log folder, there is one file called dev.log with this:

2023-06-01T15:46:05.158715+00:00] deprecation.INFO: User Deprecated: The "Monolog\Logger" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Bridge\Monolog\Logger". {"exception":"[object] (ErrorException(code: 0): User Deprecated: The "Monolog\Logger" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Bridge\Monolog\Logger". at /home/serverid/myrootadon/releases/4/vendor/symfony/error-handler/DebugClassLoader.php:338)"} []

I have this:

# Options All -Indexes
<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteBase /
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ public/index.php [QSA,L]
</IfModule>

in two .htaccess files: /home/serverid/myrootadon/.htaccess and /home/serverid/myrootadon/public_html/.htaccess.

The database connection is working, if I do this from the console:

$ php current/bin/console  dbal:run-sql "SELECT * from post";

I can see the rows into the post table.

And the routes are defined:

$ php current/bin/console debug:router

 -------------------------- -------- -------- ------ ----------------------------------- 
  Name                       Method   Scheme   Host   Path                               
 -------------------------- -------- -------- ------ ----------------------------------- 
  _preview_error             ANY      ANY      ANY    /_error/{code}.{_format}           
  _wdt                       ANY      ANY      ANY    /_wdt/{token}                      
  _profiler_home             ANY      ANY      ANY    /_profiler/                        
  _profiler_search           ANY      ANY      ANY    /_profiler/search                  
  _profiler_search_bar       ANY      ANY      ANY    /_profiler/search_bar              
  _profiler_phpinfo          ANY      ANY      ANY    /_profiler/phpinfo                 
  _profiler_xdebug           ANY      ANY      ANY    /_profiler/xdebug                  
  _profiler_search_results   ANY      ANY      ANY    /_profiler/{token}/search/results  
  _profiler_open_file        ANY      ANY      ANY    /_profiler/open                    
  _profiler                  ANY      ANY      ANY    /_profiler/{token}                 
  _profiler_router           ANY      ANY      ANY    /_profiler/{token}/router          
  _profiler_exception        ANY      ANY      ANY    /_profiler/{token}/exception       
  _profiler_exception_css    ANY      ANY      ANY    /_profiler/{token}/exception.css   
  app_post                   ANY      ANY      ANY    /post                              
  post_show                  ANY      ANY      ANY    /post/{id}                         
 -------------------------- -------- -------- ------ ----------------------------------- 

If I try to navigate to: https://example.com/post/1 I have Error 500 too, when the post with id=1 exists in the database.

All this works perfectly locally but when I deploy it to the remote server I can't get it to work nor can I find where the 500 error is. I don't see anything in the browser console either.

in flag
`info` level messages are irrelevant. If Apache is not writing a proper error message in the log files increase the log level.
in flag
It's also possible that the log you checked comes from PHP, not from Apache. In that case check the correct log files.
A. Cedano avatar
eg flag
@GeraldSchneider in `monolog.yaml` I have: `level: debug`
in flag
This does not affect Apache logging.
A. Cedano avatar
eg flag
@GeraldSchneider I don't have access to Apache logs, because I'm working in a shared hosting.
in flag
Then contact your hoster. The web server logs are your only chance to find the problem.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.