Link to home
Start Free TrialLog in
Avatar of Marthaj
MarthajFlag for United States of America

asked on

Virtual Host Entry and ProjectConfiguration.class.php Error

I have a Symfony legacy app (1.1.7) that I am trying to load on a Ubuntu 20.04 server - Apache 2.4 and it's not going well. I did not use composer to load Symfony 1.1.7. I used the instructions from this link

 https://symfony.com/legacy/doc/getting-started/1_4/en/04-Project-Setup

Open in new window

I can not load the index.php page or any web page from the site.

I have enabled the Apache rewrite_module/headers - reloaded Apache - Apache staus is fine.

I know the project name is correct and the physical address are correct.  /var/www/api.doghomes.com

I have enabled the site - api.doghomes.com.

I have checked the directory structure/existence of the files as to being in the correct location/path.

This is the error I receive in my error log:


[Thu Feb 02 10:02:55.133725 2023] [proxy_fcgi:error] [pid 64656:tid 139704322213632] [client 127.0.0.1:35994] AH01071: Got error 'PHP message: PHP Warning:  require(/var/www/api.doghomes.com/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/api.doghomes.com/config/ProjectConfiguration.class.php on line 10\nPHP message: PHP Fatal error:  require(): Failed opening required '/var/www/api.doghomes.com/vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/api.doghomes.com/config/ProjectConfiguration.class.php on line 10\n'

Open in new window


This is the virtual host file:


<VirtualHost 127.0.0.10:80>
   ServerAdmin webmaster@api.doghomes.com
   ServerName api.doghomes.com   
   DocumentRoot /var/www/api.doghomes.com/web


   <Directory />
      AllowOverride None
      Order Deny,Allow
      Deny from All
   </Directory>


     <Directory /var/www/api.doghomes.com/web>
        Options FollowSymLinks
        AllowOverride None
        Allow from all


        Satisfy Any


       <IfModule mod_headers.c>
            <FilesMatch "(page-.+|cover).swf$">
                Header Set Cache-Control "max-age=0"
            </FilesMatch>
        </IfModule>
      <IfModule mod_rewrite.c>
                   RewriteEngine On


                   RewriteBase /


                   # Prevent cybercrime
                   RewriteRule ^[pP]hp[mM]y[Aa]dmin /errors/403.html [L,QSA]


              # we skip all files with .something
              RewriteCond %{REQUEST_URI} \..+$
              RewriteCond %{REQUEST_URI} !\.html$
              RewriteCond %{REQUEST_URI} !\.pdf$
              RewriteRule .* - [L]


              # we check if the .html version is here (caching)
              RewriteRule ^$ admin.php
              RewriteRule ^$ index.html [QSA]
              RewriteRule ^([^.]+)$ $1.html [QSA]
              RewriteCond %{REQUEST_FILENAME} !-f


             # no, so we redirect to our front web controller
             RewriteRule ^(.*)$ index.php [QSA,L]
  
  
   </IfModule>


      # big crash from our front web controller
      ErrorDocument 500 "<h2>Application error</h2>symfony application failed to start properly"
   </Directory>


   <Directory /var/www/api.doghomes.com/web/schema/>S
           AllowOverride All
        </Directory>
   ErrorLog /var/log/apache2/api.doghomes.com.error.log


   # Possible values include: debug, info, notice, warn, error, crit,
   # alert, emerg.
   LogLevel info


   CustomLog /var/log/apache2/api.doghomes.com.access.log combined
   ServerSignature On
</VirtualHost>

Open in new window

This is the ProjectConfiguration.class.php file:


<?php


require_once dirname(__DIR__) . '/vendor/symfony/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();


class ProjectConfiguration extends sfProjectConfiguration
{
    public function __construct()
    {
        require dirname(__DIR__) . '/vendor/autoload.php';


        // Add `<root>/vendor` to the include path
        $appRoot = realpath(dirname(dirname(__FILE__)));
        $paths = array(
            get_include_path(),
            $appRoot . '/vendor',
        );
        set_include_path(implode(PATH_SEPARATOR, $paths));


        parent::__construct();
    }
}

Open in new window

When I enter http://localhost/api.doghomes.com/index.php or 127.0.0.10:80//api.doghomes.com/index.php

I receive this error:

The requested URL was not found on this server.
Apache/2.4.41 (Ubuntu) Server at localhost Port 80

Open in new window

If I enter this: api.doghomes.com/index.php, I receive this error:

This page isn’t working

api.doghomes.com is currently unable to handle this request.
HTTP ERROR 500

Open in new window


I don't pretend that I understand everything in the virtual host entry but I get the general gist that it is checking for certain page types and if so, rewriting/appending to end of page. i.e if this (or not this) then...and QSA -if url is re-written to add to end of it.

I do have the entry 127.0.0.10 in my host file.

I have also tried commenting out the references to the <IfModule> etc - restart - reload etc and it still spits in my face. It still spits in my face. Any help/insights appreciated.

Avatar of Patrick Barnhardt
Patrick Barnhardt
Flag of United States of America image

The documentation you've linked says the require path should be different than what you've shared.

// config/ProjectConfiguration.class.php
require_once dirname(__FILE__).'/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php';

Open in new window


You've got

require_once dirname(__DIR__) . '/vendor/symfony/autoload/sfCoreAutoload.class.php';

Open in new window


And the error is indicating it cannot find that file.

You are denying all access to the base path /

Lines 7-15 from your http conf.

You either need to delete /web from the documentRoot setting
Or comment out the items from lines 7-10.
You could deny browsing  of the directory before /web
Or add an index page in the root to bounce the user along ...
ASKER CERTIFIED SOLUTION
Avatar of dfke
dfke

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Marthaj

ASKER

thank you all for responding.
Patrick/Arnold - you both have valid points.
dfke - Last night I  discovered the same thing - file doesn't exist - thank heavens for logs! And also read where it has been deprecated starting with Php 7.2. Good to know since it is going to be upgraded to at least PHP 7.x if not 8.x
I am very new to Symfony - almost a year of experience - and just trying to get this app installed so I can work with it using localhost.
Sigh..
Avatar of Marthaj

ASKER

I did some experimenting and the results are better but the problem is not solved.
I stripped my virtual config to this:

<VirtualHost 127.0.0.10:80>       
       
       ServerAdmin webmaster@doghomes.com
       
       ServerName www.doghomes.com

       DocumentRoot "/var/www/www.doghomes.com/web"
        
       DirectoryIndex index.html
       
      <Directory "/var/www/www.doghomes.com/web>"
            Options -Indexes +FollowSymLinks
            AllowOverride none
            Allow from all
       </Directory>

	ErrorLog ${APACHE_LOG_DIR}/sunday-test-www.doghomes.com.error.log
	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel info

	CustomLog ${APACHE_LOG_DIR}/sunday-test-www.doghomes.com.access.log combined
</VirtualHost>

Open in new window


And added 127.0.0.10 to host file - did the enable www.doghomes.com - reload apache2 - check status - and all was well.
Apache2 did not show any errors and the syntax was checked by apache2ctl configtest - was ok.

The file - index.html does exist in the folder /var/www/www.doghomes.com/web.
When I enter this into my browser:

http://localhost/www.doghomes.com/index.html

or this:
http://localhost/www.doghomes.com/

This is what I receive in the error logs:

Sun Feb 05 10:40:59.049436 2023] [core:info] [pid 32223:tid 140190503728896] [client ::1:46094] AH00128: File does not exist: /var/www/www.doghomes.com/web/www.doghomes.com/index.html

[Sun Feb 05 10:41:50.459808 2023] [reqtimeout:info] [pid 32224:tid 140190503728896] [client ::1:46096] AH01382: Request header read timeout
[Sun Feb 05 10:43:21.851180 2023] [reqtimeout:info] [pid 32223:tid 140190416893696] [client ::1:48684] AH01382: Request header read timeou

Open in new window


I fail to understand how it is picking up www.doghomes.com twice.
Any help appreciated.
Avatar of dfke
dfke

Hi,

Sun Feb 05 10:40:59.049436 2023] [core:info] [pid 32223:tid 140190503728896] [client ::1:46094] AH00128: File does not exist: /var/www/www.doghomes.com/web/www.doghomes.com/index.html

The path to your index file looks incorrect.  


Cheers
Avatar of Marthaj

ASKER

A little more experimenting. I changed the permissions on the entire directory - just to see.
And copied an phpinfo.php page that I created into the  /var/www/www.doghomes.com/web/ directory.
Did the stop/start website/apache etc.
If I enter this address:
http://www.doghomes.com/phpinfo.php

it will load my page but not any of the pages already existing in the directory.
If I try any of them, it simply displays:

This page isn’t working www.doghomes.com is currently unable to handle this request.
HTTP ERROR 500

Open in new window

Avatar of Marthaj

ASKER

Changing the ProjectConfiguration.class.php  did help. But I have come to the conclusion that is it is also a rippling path/permissions problem.
I created a page and placed it into www.doghomes.com/web folder and was able to display it using this address:

http://www.doghomes.com/index.html

Open in new window


But if I try using //localhost etc - it will not display the page.
 I am going to close out this question and post later concerning pathing/permissions.
I thank all of you for responding.  It has been appreciated.

.