Laravel 5.4: 500 ISE without any error output - php

I've been recently working on a laravel app and when I finished it, I decided to upload it to a server through FTP. I've set up all the proper folders in the storage/ directory and chmodded them to 777. ModRewrite is setup on the server, but I still get a 500 ISE without any log stack displayed in browser. I don't have access to Apache logs, so cannot check what's wrong. Please, could you give me some suggestions on what can be wrong and how to fix this? (The app was working absolutely fine on my local server on PC)

Finally got it working by executing:
php composer.phar dump-autoload
php composer.phar install
(The second one only generated optimized class loaders, because everything was installed earlier)

php artisan key:generate
Assuming permissions are right, I'd say it has to do with missing encryption key.

Related

Laravel 8 ERROR 500 - INTERNAL SERVER ERROR in cpanel

I have successfully used Laravel on my local machine and it worked. But, when I put it on my online cPanel I can access the login page, but any other page behind the login page is producing the error
ERROR 500 - INTERNAL SERVER ERROR
I have checked my online PHP version and it's 7.4.14, while the local version is PHP 7.4.9. I believe that it should not make much difference.
I would be grateful for anything that can helpful.
I've also checked the MySQL version:
cPanel version 5.6.41-84.1
local version 5.7.14
The information shared is not enough to provide a solution. You can try generating the error log first. It looks like the permission for your log file is not set.
Can you try these two command to provide permission on laravel storage folder and bootstrap. Go to the application directory and issue following commands.
chmod 777 -R storage
chmod 777 -R bootstrap/cache

Display file from Storage path laravel

I have a file stored in storage directory in Laravel 7. The sub directory is storage/app/public/personnel-docs/nameofile.ext.
I have done php artisan storage:link and therefore, on my local which is a windows 10 machine I can access it by the following url
http://127.0.0.1:8000/storage/personnel-docs/nameofthefile.ext
But where it is hosted on a LIVE linux server, when I try the same url as follo
http://theliveurl/storage/personnel-docs/nameofthefile.ext
It returns a 404 Not found response.
I have also run php artisan storage:link on the server and the problem persists.
I have checked and confirmed that the file is present on the folder but it just does not return/display as expected.
I will appreciate any effort to resolve this.
Thank you

Run laravel project in localhost

I have installed laravel by composer create-project laravel/laravel –-prefer-dist
after this run php artisan serve command to laravel project directory and get this result.
Laravel development server started: http://127.0.0.1:8000
But when i go to http://127.0.0.1:8000 in browser laravel project not running and give error
This site can’t be reached
127.0.0.1 refused to connect.
but http://localhost/laravel/public/ it is working. Can anyone tell me that what is proper way to run this laravel project.
Try to run in different port
php artisan serve --port=9000
and then try http://127.0.0.1:9000 will work.
As might be on port 8000 something already running on your system will not make it work.
And you can also run your laravel project without artisan serve command
If anyone wants to make the application public, the more easy and fastest way is:
Rename the "server.php" file in root directory, in "index.php"
Move your .htaccess from public folder to root directory
Make your directory accessible to Apache2 (set all file permissions
to 777).
At starting level, you can use url like this http://127.0.0.1:8000 with port-number. but in further level you must working with simple url like http://localhost/laravel/public/.
One more thing - you should remove "public" keyword from url, so you access direct your root-project. Review this link - Laravel 5 - Remove public from URL
I had that problem too! And couldn't solve it. So I installed openserver from https://ospanel.io/ and put my site on the folder domains (Windows 10), then I just start Open Server and click "My Sites" and choose my site - it opened in my browser which set by default on Open Server program and click the folder on my browser cooled "public" and there you go -> your site is working.
I now that isn't solve the problem with cmd and start thought cmd and server like http://127.0.0.1:8000, but you can take access to your local site through http://'your site'/public/'your pages'
Good luck!
Changing the port will help.
php artisan serve --port=9000
worked for me
Try this
php -S 127.0.0.2:8000 -t public/
It will start your local development to http://127.0.0.2:8000 which will work great.
OR
You can try instead
php -S 127.0.0.1:8000 -t public/ It will work in any browser as compare to command php artisan serve which open url http://127.0.0.1:8000.
Successfully landed to Laravel page by the following steps.
Note: This is after the successful installation and configuration.
Was in /var/www/html/
Created the project using the following command after Laravel installation successfully
$laravel new firstapp
here firstapp is my project
cd to firstapp (folder created with project creation with $laravel new firstapp)
serve using the following command
$ php artisan serve
The project ready to serve with the following statement as below
Laravel development server started: http://127.0.0.1:8000
You can access the laravel page using the following URL
http:///firstapp/public/
Sometimes this occur when you have installed an anti virus software. Anti-virus deleting your "server.php" file. For that you can create an exception in anti-virus for "server.php" file or creating a "server.php". You can find relevant code for the file searching. Basically server refuse to connect occurs when the "server.php" deleted or removed from the file path.

PHP site developed using Laravel 5 is not getting rendered after Hosting

I developed a php site using Laravel 5 and tried hosting it in a LAN Server running UBUNTU 14. But when I navigated the page I'm just getting a Blank Page. No errors at all. I inserted a simple echo statement in index.php and I got the relevant echo.
There can be many reason. If you are using Laravel 5.0, you will need at least PHP 5.4. For Laravel 5.1, you will need 5.5.9. But if you have installed PHP using sudo apt-get install php5 you are most likely to have PHP 5.5.9 or later. Because that is the default version for Ubuntu 14.04 LTS. try running php -v from terminal to check the version.
There can also be a Permission issue for storage folder.
From project root folder run following command,
sudo chmod 755 -R storage
Basically, laravel needs write access to storage folder to write a log in storage/log directory or to write a compiled view files in storage/framework/views etc. You can try 755 first. If that does not work try 777.
Laravel shows nothing on certain fatal errors. For instance a class that can't be found or the storage directory and subdirectories that should be writable for the web user (www-data). This should show up in the error log of the webserver.
I believe you have permissions issue chmod 755 storage folder located in the root of your web project. If that doesn't works do it 777.
The reason why echo in the index.php is working is because this is the first file called when you execute the laravel app and the index file calls services provider and other required files, in this process the app creates a cache file under storage/framework/views/ folder but these files does not have write permissions, but as you echo something you get that output because it has been called even before anything was called.

PHP exec('git') failing

Specifically, I'm trying to get ViewGit working on a PHP/Apache/Windows installation.
It seems that PHP is unable to run exec('git');.
exec('whoami'); works just fine, so it isn't a problem with exec() being disabled.
Apache is running under it's own user account- if I log in as this user and attempt to run git on the command line I get the expected results. The account also has full permissions to do everything with the /Program Files/Git folder.
If I run exec('git'); on my local machine it works fine, but just won't work on the server.
Any ideas?
When you type 'git' in command-line on Windows, it opens git.cmd. In typical msysgit installation on Windows, git.cmd is in PATH, but git.exe may not be!
So, you can try one of below:
Create a git.bat in Windows folder with following contents:
C:\Program Files (x86)\Git\bin\git.exe (check path)
Add git's bin directory also in Windows PATH. (You can do so by editing system environmental variables)
I've managed to fix this by upgrading from PHP 5.2 to PHP 5.4. Not sure what the issue was, but that has resolved it.

Categories