5
votes

Im getting this when requesting sorial/app_dev.php:

Not Found

The requested URL /app_dev.php/ was not found on this server.

And when requesting sorial/app.php:

unregister(); $apcLoader->register(true); */ $kernel = new AppKernel('prod', false); $kernel->loadClassCache(); //$kernel = new AppCache($kernel); // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter //Request::enableHttpMethodParameterOverride(); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response);

Im on Ubuntu 14.04 and Apache 2.4

EDIT: This is my virtual host:

<VirtualHost *:80>
    ServerName sorial
    #ServerAlias sorial.es
    DocumentRoot /var/www/sorial/web
        DirectoryIndex app.php
    #SetEnv SYMFONY__DATABASE__PASSWORD jander
    <Directory /var/www/sorial/web/>
        # Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        #Order allow,deny
        #allow from all
        Require all granted
        FallbackResource /index.php
        # BEGIN EXPIRES
        <IfModule mod_expires.c>
            ExpiresActive On
            ExpiresDefault "access plus 10 days"
            ExpiresByType text/css "access plus 1 week"
            ExpiresByType text/plain "access plus 1 month"
            ExpiresByType image/gif "access plus 1 month"
            ExpiresByType image/png "access plus 1 month"
            ExpiresByType image/jpeg "access plus 1 month"
            ExpiresByType application/x-javascript "access plus 1 month"
            ExpiresByType application/javascript "access plus 1 week"
            ExpiresByType application/x-icon "access plus 1 year"
        </IfModule>
        # END EXPIRES
    </Directory>
</VirtualHost>

And my document root is at /var/www/sorial/web.

The truth is I have the same problem for the rest of my sites. The problem started when I try to disable/enable env_mod using a2dismod env, since when adding the variable SetEnv (as you can see in my virtual host) I was getting

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.

when restarting apache.

4
Have you tried to run you app with this command: php bin/console server:run?Giovani
Can you show us your Apache VirtualHost or DirectoryRoot configuration? I'm wondering what did you specify for the web directory?Alvin Bunk
@Giovani thanks, that is working, but I prefer to use Apache.ziiweb
@AlvinBunk I edited my question.ziiweb
Why if your VH is named sorial you try to get my_site/app_dev.php instead of sorial/app_dev.php ? or it's a typo?yceruto

4 Answers

4
votes

I finally solved my problem installing php5 and libapache2-mod-php5 like this: sudo apt-get install php5 libapache2-mod-php5

2
votes

I finally solved my problem installing php5 and libapache2-mod-php5 like this: sudo apt-get install php5 libapache2-mod-php5 — @ziiweb

The error you received is usually caused by missing or corrupted configuration files.

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.

The journalctl command can be used to see more details.

$ journalctl | tail
AH00526: Syntax error on line 5 of /etc/apache2/sites-enabled/mydomain-wsf.lan.conf

You can also do an Apache configuration test.

$ apachectl configtest
Syntax OK

$ sed -i 's/SetEnv/SetEnvFoobar/' /etc/apache2/sites-enabled/test.conf

$ apachectl configtest
AH00526: Syntax error on line 12 of /etc/apache2/sites-enabled/test.conf:
Invalid command 'SetEnvFoobar', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.

The apachectl graceful command is also very useful. It restarts Apache, but runs a configtest first "before initiating the restart to make sure Apache doesn't die."

apachectl graceful

Gracefully restarts the Apache httpd daemon. If the daemon is not running, it is started. This differs from a normal restart in that currently open connections are not aborted. A side effect is that old log files will not be closed immediately. This means that if used in a log rotation script, a substantial delay may be necessary to ensure that the old log files are closed before processing them. This command automatically checks the configuration files as in configtest before initiating the restart to make sure Apache doesn't die. This is equivalent to apachectl -k graceful

Apache Docs

Reinstalling software can work because it will fix any missing configurations files.

$ apt-get install --resinstall libapache2-mod-php5 php5 

Another alternative, noted here, is to purge and then install. It is very important to know however, that purge is a destructive command meaning it will delete all existing configurations files. This is pretty much the equivalent of a fresh install.

$ apt-get purge libapache2-mod-php5 php5
$ apt-get install libapache2-mod-php5 php5 
1
votes

Ok, I had the same problem using Debian with apache as server. Try to replace your .htaccess inside web directory and clear the cache.

DirectoryIndex app.php

<IfModule mod_negotiation.c>
  Options -MultiViews
</IfModule>

RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app_dev.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] 
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app_dev.php [L] 

And this should be your virtual host

<VirtualHost *:80>
 ServerName sorial

 DocumentRoot /var/www/sorial/web
 <Directory /var/www/sorial/web>
    AllowOverride All
    Order Allow,Deny
    Allow from All

 </Directory>

 ErrorLog /var/log/apache2/project_error.log
 CustomLog /var/log/apache2/project_access.log combined

</VirtualHost>
1
votes

Actually, in my config I'm using .htaccess files, and I see you've commented out the Options line. I wonder if you had a reason for that?

If not, I would suggest uncommenting it like so:

<Directory /var/www/sorial/web/>
    Options Indexes FollowSymLinks MultiViews

See if that works.