I host a SPA with a Laravel API on AWS (EC2). When you fill out this form: http://ec2-52-59-214-55.eu-central-1.compute.amazonaws.com/register (feel free to do so), the server throws an error with a response code of 500, right at the point where a $user->can("...") method is called. I developed the app localy and everything worked fine there.
Local environment:
Windows 10 / XAMPP - Apache 2.4.41
PHP 7.4.4
Laravel 7.5.2
Server environment:
Ubuntu 18.04 / Apache 2.4.29
PHP 7.4.6
Laravel 7.5.2
It uses spatie/laravel-permission for role management, which also affects the can method provided by the Laravel framework.
Here is the code causing the error:
echo "Before store<br>";
if($user->can("store files")) { echo "Inner store";
// Store avatar
if(isset($data["avatar"])) {
if(!$data["avatar"]->isValid()) {
return reponse(null, 422);
}
// Check if avatar is new
$current_avatar = $user->getAvatarAttribute();
$store_images = get_new_files([$data["avatar"]], [$current_avatar]);
if(isset($store_images[0])) {
// Create asset for avatar
$new_avatar = create_asset([
"file" => $store_images[0],
"user_id" => $user->id,
"type" => "avatar"
]);
$new_avatar->save();
}
}
}
echo "After store<br>";
And here the error which I guess means, that the script failed as soon as if($user->can("...)) got called.
Do you have any idea how to fix that?
Logging errors are fairly common, especially when configured as a daily log.
https://laravel.com/docs/7.x/logging#configuration
Specifically look at the section on "Configuring The Single and Daily Channels" as this allows the permissions of the log file to be set on creation.
Temporarily, you can change the permissions for you logs like so:
sudo chmod 644 storage/log/.
Related
I mistakenly ran my laravel application on debug mode in my production environment, and it threw an error for me to change App_debug:true to App_debug:false, which I did, ever since then, my site has been throwing an HTTP ERROR 500
"This page isn’t working admin.robyhub.com is currently unable to handle this request.
HTTP ERROR 500"
I then went on to my cpanel terminal and tried to clear the logs on the config file but it gives me the below error.
[thehcerl#premium261 admin.robyhub.com]$ php artisan config:clear
Symfony\Component\Finder\Exception\DirectoryNotFoundException
The "/home/thehcerl/admin.robyhub.com/resources/lang/ha" directory does not exist.
at vendor/symfony/finder/Finder.php:590
586▕ } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? \GLOB_BRACE : 0) | \GLOB_ONLYDIR | \GLOB_NOSORT)) {
587▕ sort($glob);
588▕ $resolvedDirs = array_merge($resolvedDirs, array_map([$this, 'normalizeDir'], $glob));
589▕ } else {
➜ 590▕ throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
591▕ }
592▕ }
593▕
594▕ $this->dirs = array_merge($this->dirs, $resolvedDirs);
+2 vendor frames
3 app/Providers/TranslationServiceProvider.php:40
Illuminate\Support\Facades\Facade::__callStatic()
4 app/Providers/TranslationServiceProvider.php:27
App\Providers\TranslationServiceProvider::phpTranslations()
Cpanel Terminal
Ever since I changed debug to false on my .env from my laravel project main directory because the laravel documentation warned me to not use debug mode on a non-local environment. I expected my application would automatically stop receiving the laravel debug config solutions and would run properly.
This is not a very generic error, it's as a result of an error on my part, I created language folders that I did not link to my PHP "translationProvider.php" file, so it invariably gave me that issue.
I was using a purchased template from Envato so I hadn't taken the time to get the full inner working of the backend at the time.
If anyone has a similar error I hope this will guide you not to make the mistakes I made, and meticulously look through your code when making changed or edits.
Thanks, happy coding.
I'm trying to create my first SilverStripe website following this tutorial.
So far I have created my website and configured my .env page.
# DB credentials
SS_DATABASE_CLASS="MySQLDatabase"
SS_DATABASE_SERVER="localhost"
SS_DATABASE_USERNAME="root"
SS_DATABASE_PASSWORD=""
SS_DATABASE_NAME="SS_examples"
SS_ENVIRONMENT_TYPE="dev"
I'm not sure entirely how the database is created when creating a site. I checked my databases and I do not have one for it. I can make one manually but I wasn't sure if I should and list it under SS_DATABASE_NAME, or if it will auto-create the db.
I'm assuming this is why when I visit my local site localhost/SSexample/public I get an error saying "The website server has not been able to respond to your request".
Am I missing a step in setting up the site or should I manually create a db named SS_examples?
on a side note my apache server is set up with xampp and my SilverStripe project is in C:/xamp/htdocs.
Steps I took to create site:
Built site in C:\xampp\htdocs by running: composer create-project silverstripe/installer SSexample
Visited my project by going to localhost/SSexample/public
created .env file as listed above
ERROR LOGS
[2019-12-31 22:29:22] error-log.ERROR: Uncaught Exception SilverStripe\ORM\Connect\DatabaseException: "Couldn't run query: SELECT DISTINCT "SiteConfig"."ClassName", "SiteConfig"."LastEdited", "SiteConfig"."Created", "SiteConfig"."Title", "SiteConfig"."Tagline", "SiteConfig"."CanViewType", "SiteConfig"."CanEditType", "SiteConfig"."CanCreateTopLevelType", "SiteConfig"."ID", CASE WHEN "SiteConfig"."ClassName" IS NOT NULL THEN "SiteConfig"."ClassName" ELSE 'SilverStripe\\SiteConfig\\SiteConfig' END AS "RecordClassName" FROM "SiteConfig" LIMIT 1 Table 'ss_lessons.siteconfig' doesn't exist" at C:\xampp\htdocs\SSlessons\vendor\silverstripe\framework\src\ORM\Connect\DBConnector.php line 64 {"exception":"[object] (SilverStripe\\ORM\\Connect\\DatabaseException(code: 0): Couldn't run query:\n\nSELECT DISTINCT \"SiteConfig\".\"ClassName\", \"SiteConfig\".\"LastEdited\", \"SiteConfig\".\"Created\", \"SiteConfig\".\"Title\", \"SiteConfig\".\"Tagline\", \"SiteConfig\".\"CanViewType\", \"SiteConfig\".\"CanEditType\", \"SiteConfig\".\"CanCreateTopLevelType\", \"SiteConfig\".\"ID\", \n\t\t\tCASE WHEN \"SiteConfig\".\"ClassName\" IS NOT NULL THEN \"SiteConfig\".\"ClassName\"\n\t\t\tELSE 'SilverStripe\\\\SiteConfig\\\\SiteConfig' END AS \"RecordClassName\"\n\r\nFROM \"SiteConfig\"\n\r\nLIMIT 1\n\nTable 'ss_lessons.siteconfig' doesn't exist at C:\\xampp\\htdocs\\SSlessons\\vendor\\silverstripe\\framework\\src\\ORM\\Connect\\DBConnector.php:64)"} []
It seems that the installer at localhost/SSexample/public should allow you to configure your database connection settings (and create the database for you).
Getting The website server has not been able to respond to your request error means that you have a problem with webserver - is it running?
EDIT: The website server has not been able to respond to your request is actually Silverstripe's generic error 500 message.
EDIT2: one has to enable dev environment - by adding SS_ENVIRONMENT_TYPE="dev" to .env file and then access localhost/SSexample/public/dev/build to get database created and populated.
I have developed a website using PhalconPHP. the website works perfectly fine on my local computer with the following specifications:
PHP Version 7.0.22
Apache/2.4.18
PhalconPHP 3.3.1
and also on my previous Server (with DirectAdmin):
PHP Version 5.6.26
Apache 2
PhalconPHP 3.0.1
But recently I have migrated to a new VPS. with cPanel:
CENTOS 7.4 vmware [server]
cPanel v68.0.30
PHP Version 5.6.34 (multiple versions available, this one selected by myself)
PhalconPHP 3.2.2
On the new VPS my website always gives me Error 500.
in my Apache Error logs file: [cgi:error] End of script output before headers: ea-php70, referer: http://mywebsitedomain.net
What I suspect is the new database System. the new one is not mySql. it is MariaDB 10.1. I tried to downgrade to MySQL 5.6 but the WHM says there is no way I could downgrade to lower versions.
this is my config file:
[database]
adapter = Mysql
host = localhost
username = root
password = XXXXXXXXXXXX
dbname = XXXXXXXXXXXX
charset = utf8
and my Services.php:
protected function initDb()
{
$config = $this->get('config')->get('database')->toArray();
$dbClass = 'Phalcon\Db\Adapter\Pdo\\' . $config['adapter'];
unset($config['adapter']);
return new $dbClass($config);
}
And in my controllers...
for example this code throws Error 500:
$this->view->files = Patients::query()->orderBy("id ASC")->execute();
but changing id to fname fixes the problem:
$this->view->files = Patients::query()->orderBy("fname ASC")->execute();
or even the following code throws error 500:
$user = Users::findFirst(array(
"conditions" => "id = :id:",
"bind" => array("id" => $this->session->get("userID"))
));
is there a problem with the compatibility of PhalconPHP and MariaDB?
MariaDB was built to be mostly compatible with MySQL clients, it's unlikely to be the reason for your problems. If you're still concerned, you can switch from MariaDB to MySQL (and vice versa) by dumping (exporting) your tables, switching over, and importing them again.
More likely, the error line you're showing indicates that your new server is actually running PHP7 (ea-php70) and not PHP5.6 as you thought you selected.
The error End of script output before headers means the CGI script (in this case PHP7 itself) did not produce any HTTP headers before terminating. I suspect that your version of PhalconPHP is incompatible with PHP7 and therefore just crashes immediately.
If cPanel doesn't let you properly configure your infrastructure you likely have no other option but to drop it and set up your stack manually. But since you probably paid for cPanel, you could try opening a support ticket with them first: https://cpanel.com/support/
Most probably old phalconPHP version it does not support latest php 7.x version i guess. as i remember I have read similiar problem in another blog question.
Mediawiki Version 1.27
Visual Editor Version 1.27
Parsoid Version latest in repository
So I have several web servers running on an Ubuntu VM. The hostname is "atocha". I have Apache running on port 8000. Under this I have a Mediawiki instance. The mediawiki instance is not private.
I installed Parsoid and it is running on port 8142.
I can access my mediawiki instance by going do "http://atocha:8000/mediawiki/index.php"
I can curl the Mediawiki api just fine. "http://atocha:8000/mediawiki/api.php"
However when I try to edit the pages using Visual Editor I receive the following error "Error loading from server: 404: docserver-http: HTTP 404. Would you like to retry?" that pops up in a display. No error is thrown in Apache.
Here is my parsoid local settings.js file
'use strict';
exports.setup = function(parsoidConfig) {
parsoidConfig.setMwApi({
uri: 'http://atocha:8000/mediawiki/api.php',
domain: 'atocha',
prefix: 'atocha'
});
parsoidConfig.useSelser = true;
};
Here is the pertinent LocalSettings.php section:
wfLoadExtension( 'VisualEditor');
// Enable by default for everybody
$wgDefaultUserOptions['visualeditor-enable'] = 1;
// Don't allow users to disable it
$wgHiddenPrefs[] = 'visualeditor-enable';
$wgVirtualRestConfig['modules']['parsoid'] = array(
// URL to the Parsoid instance
// Use port 8142 if you use the Debian package
'url' => 'http://127.0.0.1:8142'
);
If I try to use parsoid like this in a browser:
http://atocha:8142/localhost/v3/page/Javadoc_Basics
I get this error:
Did not find page revisions for V3/page/Javadoc_Basics
If I try parsoid like this however:
http://atocha:8142/localhost:8000/v3/page/Javadoc_Basics
I get this:
Cannot GET /atocha:8000/v3/page/Javadoc_Basics
Anyone have an idea about what's going on? Thanks in advance.
After much failure I was able to get parsoid and visual editor working.
Here is how I did it:
https://www.mediawiki.org/wiki/Parsoid/Developer_Setup
Follow Option 2 for developer setup.
Run the tests
Change the config.yaml file for mediawiki settings and changed port number
Create UpStart job
Enjoy
I followed Fideloper post about running laravel with hhvm, step by step. There are two projects hosted on my server, one is my blog which is based on wardrobe (laravel 4.1), and another project with laravel 5.
My blog has no issue with server errors and laravel log file; But the other project cannot create log files, and it won't show error page because of that.
I double checked storage folder permission. It is 777.
When I run php artisan serve (native php, not hhvm) and browse to it, the error page showed up, and log file was created. So something is wrong with hhvm I think.
How can I fix blank page, when running laravel 5 with hhvm, and an error occurred? How can I bring back the error page (or whoops page)
P.S. I have read related question like this and still have the problem.
P.S.S. If any information needed ask me and I will update the question.
I suffered the same problem when I installed Laravel Homestead with HHVM. If you enter some random junk like sdfkjl into your routes file you'll get a blank page (however, if add a semi-colon sdfkjl; you get error output). The errors are being logged at /var/log/hhvm/error.log but they don't go to the browser, instead you just get a blank page. It appears this is intentional behavior for HHVM. It also appears Laravel tries to handle these but doesn't catch some of the fatals sent by HHVM. Thanks to clues from this github issue I decided to make some slight changes to Laravel's Foundation\Bootstrap\HandleExceptions.php to see if I could get it to catch all of these fatals:
First, update your /etc/hhvm/php.ini and add these settings:
hhvm.server.implicit_flush = true
hhvm.error_handling.call_user_handler_on_fatals = true
Before modifying a package source, let's remove the vendor\compiled.php with this artisan command:
$ php artisan clear-compiled
And let's set the environment sessons to array:
in your .env
SESSION_DRIVER=array
(You may also need to clear all the random-looking session files in storage/framework/sessions)
Now any changes we make to the Laravel package source will immediately reflect. Let's update a few things in the HandleExceptions class:
in vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php
// **** Add this to hold fatal error
protected static $fatalError = null;
...
public function handleError($level, $message, $file = '', $line = 0, $context = array())
{
// **** Add this, loads fatal error
if ($level & (1 << 24)) {
self::$fatalError = array(
'message' => $message,
'type' => $level,
'file' => $file,
'line' => $line
);
}
if (error_reporting() & $level)
{
throw new ErrorException($message, 0, $level, $file, $line);
}
}
...
// *** Update this function so it can handle the fatal
public function handleShutdown()
{
$error = error_get_last();
if(self::$fatalError){
$error = self::$fatalError;
}
if ( ! is_null($error) && $this->isFatal($error['type']))
{
$this->handleException($this->fatalExceptionFromError($error, 0));
}
}
...
protected function isFatal($type)
{
// *** Add type 16777217 that HVVM returns for fatal
return in_array($type, [16777217, E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE]);
}
...
Now type the random junk (no semi-colon) in your routes folder and you'll see the fatal display. I have now reported this issue to Taylor on the Laravel github. If you are in Lumen, I've got a solution here that will work until Lumen gets fixed as well.
I also got the same issue. Give 755 permission to entire laravel project it's work for me
anyway you can check hhvm error log, run
$tail -n 50 -f /var/log/hhvm/error.log