1

I have a website which I'm trying to run offline on my LAMP server but when I'm trying to enter it with localhost or with local ip address the page is blank.

If I'm opening the Inspector I can see all the elements and if I'm hovering on an element in the inspector I can see where in the page they are located but they're invisible.

I checked the apache log file and saw that error (line breaks for more comfortable view):

[:error] [pid 3180] [client 127.0.0.1:60802] PHP Fatal error:  require_once(): 
Failed opening required '/var/www/html' (include_path='.:/usr/share/php') in
/var/www/html/cache/cache.php on line 572

I then searched google for a solution and found this guide but didn't manage to solve the issue.

Would be happy to get some help.

EDIT:

This is the output of ls -la:

total 12
drwxr-xr-x  3 root      root     4096 אפר  6 11:53 .
drwxr-xr-x 15 root      root     4096 אפר  6 11:53 ..
drwxrws--- 16 localhost www-data 4096 אפר  6 14:36 html

I managed to make the page visible by changing the opacity in here:

<?=($config['environment']!=='dev')?'style="opacity:0;"':''?>

To this:

<?=($config['environment']!=='dev')?'style="opacity:1;"':''?>

Now I can see the page but for some reason the CSS isn't loading.

I am also getting a lot of those:

SQL/DB Error -- [Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'sitename_site.pv.name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by]

EDIT #2:

After changing the permissions of /var/www this is the error I'm getting:

Fatal error: Uncaught exception 'RuntimeException' with message 'The file could not be written to. Check that appropriate permissions have been set.' in /var/www/html/vendor/katzgrau/klogger/src/Logger.php:128 Stack trace: #0 /var/www/html/includes/db_class.php(7204): Katzgrau\KLogger\Logger->__construct('/var/www/html/i...') #1 /var/www/html/includes/db_class.php(7217): db_class->getLogger('404') #2 /var/www/html/includes/furl_router.php(55): db_class->logger('404') #3 /var/www/html/includes/furl_router.php(229): goTo404('no page-data / ...') #4 /var/www/html/index.php(17): require_once('/var/www/html/i...') #5 {main} thrown in /var/www/html/vendor/katzgrau/klogger/src/Logger.php on line 128
Omer
  • 57
  • 1
  • 7
  • I assume your css/images/js don't load. – Roland Starke Apr 06 '18 at 17:19
  • @RolandStarke Why do assume it? – Omer Apr 06 '18 at 17:24
  • _"Failed opening required '/var/www/html'"_ That's likely a directory, not a file. You can't `require_once()` a directory. – Alex Howansky Apr 06 '18 at 17:25
  • @Omer because you said all the elements are there only the style is missing. Could you check the network tab? – Roland Starke Apr 06 '18 at 17:27
  • I used `include_once` – Omer Apr 06 '18 at 17:27
  • @RolandStarke I can't see the elements though it's as if there invisible. – Omer Apr 06 '18 at 17:28
  • It looks like the require_once doesn't include a specific file name or less likely a full file path. Normally you'd see require_once('/var/www/html/file.php'); – user9189147 Apr 06 '18 at 17:29
  • Ok, I was on `require_once` but originally I used `include_once`, I changed it back to `include_once` but now I don't have any fatal errors and the page is still invisible... The worst thing I have is a warning but if I'm getting a warning I still suppose to see the page, don't I? – Omer Apr 06 '18 at 17:32
  • Could you show output of `ls -la` on your `/var/www` folder? – treyBake Apr 06 '18 at 17:51
  • @ThisGuyHasTwoThumbs `total 12` `drwxr-xr-x 3 root root 4096 אפר 6 11:53 .` `drwxr-xr-x 15 root root 4096 אפר 6 11:53 ..` `drwxrws--- 16 localhost www-data 4096 אפר 6 14:36 html` I managed to get past it by changing this: `=($config['environment']!=='dev')?'style="opacity:0;"':''?>` To this: `=($config['environment']!=='dev')?'style="opacity:1;"':''?>` Now I can see the page but I can't see the CSS for some reason... – Omer Apr 06 '18 at 17:54
  • @Omer could you edit your question with the output ease, comments are hard to read :) – treyBake Apr 06 '18 at 17:55
  • @ThisGuyHasTwoThumbs Done – Omer Apr 06 '18 at 18:01

1 Answers1

0

I think you may have incorrect file permissions (let me if not the case and I'll remove my answer)

Try running below to fix:

$ sudo chown -R apache:apache /var/www
$ sudo find /var/www/ -type f -exec chmod 644 {} \;
$ sudo find /var/www/ -type d -exec chmod 755 {} \;

Change Apache to your user and you're good to go. It changes file owner to you recursively, then it finds everything that is a file, and sets permissions to 644 and anything that's a directory to 755 - hope this helps.

treyBake
  • 6,440
  • 6
  • 26
  • 57
  • Done it, now I'm getting a new error with the `katzgrau` package, I'm editing the original question since the error is too long – Omer Apr 06 '18 at 18:26
  • @Omer not familiar with that package but does it essentially run the service? If so you may need to chown to that related user (similar to how Apache adds an Apache user) – treyBake Apr 06 '18 at 18:57