appstract / laravel-opcache

Laravel Package for OPcache
MIT License
1.34k stars 119 forks source link

[Appstract\LushHttp\Exception\LushRequestException] The requested URL returned error: 500 Internal Server Error #30

Closed umairiftikhar-ca closed 7 years ago

umairiftikhar-ca commented 7 years ago

Hi, I'm working with my staging environment, Laravel 5.1

On running, php artisan opcache:status or php artisan opcache:clear I get following, [Appstract\LushHttp\Exception\LushRequestException] The requested URL returned error: 500 Internal Server Error

Here are my Log

Access log

"GET /opcache-api/status? HTTP/1.0" 500 5669 "App-URL/opcache-api/status?" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Lush Http Client"

Error log Got error 'PHP message: PHP Fatal error: Class 'Illuminate\Auth\Access\AuthorizationException' not found in /path-to-vendor/appstract/laravel-opcache/src/Http/Middleware/Request.php on line 29\n', referer: App-URL/opcache-api/status?

Laravel.log staging.ERROR: exception 'Appstract\LushHttp\Exception\LushRequestException' with message 'The requested URL returned error: 500 Internal Server Error' in /path-to-vendor/appstract/lush-http/src/Request/CurlRequest.php:119

I've seen the issue https://github.com/appstract/laravel-opcache/issues/12 , but that seems to be different problem.

Kindly can you help me get through this issue !

I suspect that's because opcache can't locate framework/src/Illuminate/Auth/Access/AuthorizationException.php in 5.1 , does this package supports 5.1 ?

Here are my opcache settings: Zend OPcache

Opcode Caching => Up and Running Optimization => Enabled Startup => OK Shared memory model => mmap Cache hits => 0 Cache misses => 0 Used memory => 5465056 Free memory => 61643808 Wasted memory => 0 Interned Strings Used memory => 623112 Interned Strings Free memory => 3571192 Cached scripts => 0 Cached keys => 0 Max keys => 3907 OOM restarts => 0 Hash keys restarts => 0 Manual restarts => 0

Directive => Local Value => Master Value opcache.blacklist_filename => no value => no value opcache.consistency_checks => 0 => 0 opcache.dups_fix => Off => Off opcache.enable => On => On opcache.enable_cli => On => On opcache.enable_file_override => Off => Off opcache.error_log => no value => no value opcache.fast_shutdown => 0 => 0 opcache.file_update_protection => 2 => 2 opcache.force_restart_timeout => 180 => 180 opcache.inherited_hack => On => On opcache.interned_strings_buffer => 4 => 4 opcache.load_comments => 1 => 1 opcache.lockfile_path => /tmp => /tmp opcache.log_verbosity_level => 1 => 1 opcache.max_accelerated_files => 2000 => 2000 opcache.max_file_size => 0 => 0 opcache.max_wasted_percentage => 5 => 5 opcache.memory_consumption => 64 => 64 opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF opcache.preferred_memory_model => no value => no value opcache.protect_memory => 0 => 0 opcache.restrict_api => no value => no value opcache.revalidate_freq => 2 => 2 opcache.revalidate_path => Off => Off opcache.save_comments => 1 => 1 opcache.use_cwd => On => On opcache.validate_permission => Off => Off opcache.validate_root => Off => Off opcache.validate_timestamps => On => On

ovanschie commented 7 years ago

AuthorizationException is not present in 5.1, I pushed a new tag.

This exception is triggered when you make a request from the 'outside', which is not allowed.

vesper8 commented 7 years ago

I am getting the same error and can't figure out why. I am using Laravel 5.4 too.

I think it may have to do with my app_url. I have some redirect logic on the entry route /

Is it possible to disable opcache on a per-site basis? I enabled it on my server but it's only for another site's benefit.

umairiftikhar-ca commented 7 years ago

@ovanschie

This exception is triggered when you make a request from the 'outside', which is not allowed.

What does 'outside' means , how can I fix this kindly ? I did ssh to my linux server and ran "php artisan opcache:status" with my root user.

ovanschie commented 7 years ago

@vesper8 You can't disable it per site, but it doesn't matter on which site you clear it, because all the caches will be cleared. So maybe this works for you, or maybe have a look at the OPCACHE_URL option.

@umairiftikhar-ca you installed the latest release? Try to restart your webserver or PHP-fpm after updating

liujingyu commented 7 years ago

OPCACHE_URL=http://localhost into .env

umairiftikhar-ca commented 7 years ago

@ovanschie Yes, I've installed the latest version. But it still shows following staging server:

[Appstract\LushHttp\Exception\LushRequestException]
The requested URL returned error: 500 Internal Server Error

Log entries:

Laravel log [2017-06-02 05:30:41] staging.ERROR: exception 'Appstract\LushHttp\Exception\LushRequestException' with message 'The requested URL returned error: 500 Internal Server Error' in /vendor/appstract/lush-http/src/Request/CurlRequest.php:124

Access log [02/Jun/2017:07:30:41 +0200] "GET /opcache-api/status? HTTP/1.0" 500 21469 "https://staging-url/opcache-api/status?" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Lush Http Client"

Line#124 on CurlRequest.php is throw new LushRequestException($this, $error);

teuunn commented 7 years ago

@umairiftikhar-ca Your access log is showing a 500 on "https://staging-url/opcache-api/status". That url doesn't seems legit. What did you put in your .env under APP_URL ?

umairiftikhar-ca commented 7 years ago

@teuunn I edited the log URL above, Because I don't want to mention my website URL. Assume it's https://example.com/opcache-api/status

ovanschie commented 7 years ago

@umairiftikhar-ca did you restart your webserver / fpm?

ovanschie commented 7 years ago

@umairiftikhar-ca can you give any update?

ricardovf commented 7 years ago

I am having this problem too. Why are you calling controller methods (via URL) from the commands? Couldnt you call the APC methods direct from the commands? I know that by default APC is not enabled on CLI, but as i run the opcache:optimize on the deploy script, it would be great to not depend on the call via URL.

umairiftikhar-ca commented 7 years ago

@ovanschie Yes I started server. This is working fine on my local for Laravel 5.1 now. But I'm having same issue as i posted previously on my staging env, still trying to figure out the problem.

ovanschie commented 7 years ago

@ricardovf see https://github.com/appstract/laravel-opcache/issues/19

ovanschie commented 7 years ago

The new release v1.2 should fix most issues. Please leave a comment if you still have issues.

kamililyas commented 7 years ago

@ovanschie me and @umairiftikhar-ca are working on the same issue and no the version didnt resolve it for us

ovanschie commented 7 years ago

It's hard to say what the problem might be without having access to the environment. The only thing you can try is the update I tagged like an hour ago (1.2.1) if you haven't already, and then restart your webserver after you deployed this update.

There is nothing much more I can do from here.

kamililyas commented 7 years ago

@ovanschie yeah that didnt work either, but I understand the setup I'm trying this on and it won't work there as you have mentioned that requests are accepted from the same IP. I'm trying to run it on another independent setup but am getting this error: [Symfony\Component\Debug\Exception\FatalErrorException] Call to undefined function Appstract\Opcache\encrypt()

kamililyas commented 7 years ago

@ovanschie just verified, this error is coming in on version 1.2.1 and not on 1.2.0, so I'm moving to that one until the latest version gets fixed

ovanschie commented 7 years ago

@kamililyas there is no difference in the usage of encrypt() between 1.2.0 and 1.2.1, so don't know where that is coming from.

asterissco commented 2 years ago

I had a same problem and find this

root@laravel-server:/var/log/apache2# cat laravel-error.log [Wed Aug 03 09:13:15.763464 2022] [php:error] [pid 1856108] [client 192.168.22.1:57554] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) in [route_to_laravel]/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 70

You can fix this problem removing the limit while generate the opcache with laravel

1- Remove limit in php

root@laravel-server:/etc/php/8.1/apache2# vim php.ini ; Maximum amount of memory a script may consume ; https://php.net/memory-limit memory_limit = -1

2- Restart apache and compile

root@laravel-server:/etc/php/8.1/apache2# /etc/init.d/apache2 restart administrador@laravel-server:/path/to/laravel/project]$ php artisan opcache:compile

3- Restore the memory limit in php.ini and restart apache again