1

I just configured Symfony 3.4.15 in my Ubuntu Server and the Welcome page works, but when I want to create a new page, for example /home, with a Controller it doesn't work:

Not Found

The requested URL /home was not found on this server. Apache/2.4.18 (Ubuntu) Server at 167.99.90.60 Port 80

I follow all the steps in the Symfony Documentation, but it doesn't work...

I read that the problem is caused for my Apache2 configuration, but I don't know how to solve it.

I have LAMP installed in my Ubuntu Server.

The apache2 configuration is something like this:

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/my-project/public>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

#<Directory /srv/>
#       Options Indexes FollowSymLinks
#       AllowOverride None
#       Require all granted
#</Directory>

Here's my Virtual Host file configuration:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname $
        # the server uses to identify itself. This is used when creat$
        # redirection URLs. In the context of virtual hosts, the Serv$
        # specifies what hostname must appear in the request's Host: $
        # match this virtual host. For the default virtual host (this$
        # value is not decisive as it is used as a last resort host r$
        # However, you must set it for any further virtual host expli$
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/my-project/public

        # Available loglevels: trace8, ..., trace1, debug, info, noti$
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For ex$
        # following line enables the CGI configuration for this host $
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Any idea?

HessianMad
  • 529
  • 5
  • 19
  • I suggest to compare your configuration with the one recommended in https://symfony.com/doc/current/setup/web_server_configuration.html. For example, it misses the required rewrite rules. – xabbuh Aug 31 '18 at 12:12
  • Oh, and if you bootstrapped your application using Symfony Flex installing the Apache pack (running `composer require symfony/apache-pack`) could solve your issue too. – xabbuh Aug 31 '18 at 12:13

2 Answers2

0

My best guess is you don't have url overwrite enabled.

Have you tried using the Symfony development server?

Make sure you have something like hthis in your apache config file (usually in /etc/apache2/apache2.conf):

<Directory /var/www/>
    Options -Indexes +FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
Sodium
  • 494
  • 4
  • 13
  • No, I haven't tried the Symfony development server. It is a good idea? I tried this https://stackoverflow.com/questions/869092/how-to-enable-mod-rewrite-for-apache-2-2 and what you said about the apache2 config file but doesn't work... :( – HessianMad Aug 30 '18 at 14:00
  • 2
    Yes, the Symfony test server will save you lots of trouble in the development process. Just run php bin/console server:start in your application directory and go to http://localhost:8000 https://symfony.com/doc/current/setup/built_in_web_server.html Make also sure to check your apache configuration file. – Sodium Aug 30 '18 at 14:03
  • As you can see in my new edit, I tried changing the apache config file but still doesn't work... – HessianMad Aug 30 '18 at 14:13
  • Have you checked if it's enabled following this? https://stackoverflow.com/questions/7337724/how-to-check-whether-mod-rewrite-is-enable-on-server You can also post your virtual host configuration, it can't hurt to have more informations. – Sodium Aug 30 '18 at 14:18
  • I updated the question with my VirtualHost file configration :) – HessianMad Aug 30 '18 at 14:23
0

The problem was that I forgot to create my .htaccess file inside de /public folder.

HessianMad
  • 529
  • 5
  • 19