Saving files in a webhosting with Laravel? - laravel

I have a problem with saving files (photos) with laravel in a web hosting.
I can do it in localhost and works perfectly. But now I migrate all project to a web hosting, but saving files is not working.
The form is working, the name of file it's saved, but the file not.
I have this code into my config/filesystems.php:
'local' => [
'driver' => 'local',
'root' => public_path('web/photos'),
],
And I have this folders in public_html/web/photos Whats is wrong?

It's all about file permissions, on your web webserver you need to change it.
If you have console access:
sudo chown www-data /public_html/web/photos
sudo chmod 755 /public_html/web/photos
Or by FTP-client like so: https://www.youtube.com/watch?v=GWBwqlUhQOM

Related

System cannot open daily log file automatically in laravel

I am developing a laravel application. I am facing the laravel daily log file problem. I updated 'channels' => ['daily'] instead of 'channels' => ['single'] in the channels an array of config/logging.php file. When I login in application's live server, the new date laravel log file can not open automatically. So I am always setting this command "sudo chmod -R 777 /var/www/html/storage/logs" when I login in live server. Why can not access the new date log file automatically? Could you please help me? Thanks.

Creating symlink in Laravel (windows)

I'm currently having some problems with creating symlink in my Laravel project. I'm currently on Windows 10 OS and I'm using GitBash.
I need to create symlink from storage/app/products_content to public/products_content
For that, I'm using the following command:
ln -s storage/app/products_content public/products_content
The problem is, I'm getting the following error:
ln: failed to create symbolic link 'public/products_content': No such
file or directory
But, when I try to create a symlink like this:
ln -s storage/app/products_content products_content
It creates it with no errors, but the folder is in my root directory, not in /public.
What causes this error, could it be permission issues? I'm running GitBash as administrator. Any help appreciated. If I need to provide any additional code, let me know.
Try going into the public folder, then do:
ln -s ../storage/app/products_content products_content
And if that doesn't work, open Command Prompt (not PowerShell)
And "browse" to the public folder, then do:
mklink /D products_content ..\storage\app\products_content
mklink is the same as ln except that the target and link is switched.
Just run: php artisan storage:link and modify your path to: storage/products_content
You may configure additional symbolic links in your filesystems configuration file. Each of the configured links will be created when you run the storage:link command:
'links' => [
public_path('storage') => storage_path('app/public'),
public_path('images') => storage_path('app/images'),
],
The problem is when using windows
solution:
In my case, I am using laragon.
LINK CREATION (This is because the php artisan storage: link does not work on windows)
For this case, you will have access to images
Open cmd as administrator
Verify that public access does not work (public \ images)
Then copy in cmd: mklink / J C: \ laragon \ www \ project-name \ public \ images C: \ laragon \ www \ project-name \ storage \ app \ images
This would be similar to:
php artisan storage: link
Take into account that to save in images it must be configured in the filesytem file (conf / filesytem)
'links' => [
public_path('storage') => storage_path('app/public'),
public_path('images') => storage_path('app/images'),
],
credits : more info

How to deploy laravel 5.4 to the production server?

I generate one laravel project . Now i need to move the project to the production server. In the local system, I use php artisan serve to run the project and run http://127.0.0.1:8000/ .
while moving to the production server, I changed the .env file
APP_ENV=production
APP_DEBUG=false
APP_LOG_LEVEL=debug
APP_URL=http://myserverip
My config/app.php
'env' => env('APP_ENV', 'production'),
'debug' => env('APP_DEBUG', false),
'url' => env('APP_URL', 'http://my ip'),
I run the project (ip/projectfolder) in live it displays dirctory files listing in the browser.
Is there is any thing extra I need to configure ?

Laravel 5.4 have Blank Page - No Error Display, No Error Log

I Developed one Laravel Project. it has working in local environment properly. But, when i move the project to the server it has no error Shown. I check Error log, it has empty. i enabled APP_DEBUG=true to .env file and config/app.php also.
I give 777 permission for storage Folder. how to find error in my project, anybody help me...
Change storage and logs folder permission to : 0755
and
laravel.log file permission to : 0644
For any folder to be accessible by script, permission should be set to 0755 and for files to 0644 in standard production scenario.
This code works for me chmod -R 777 storage/
I'm using brew. Hope it could help.

Logging is not working. Yii Framework on Mac

I have an application developed on Yii Framework and it was fully working on Ubuntu 11.04 on Linux. I recently had to move it to Mac Os. At the moment is mostly working but the logging function is not. It is not writing on /protected/runtime/application.log. I granted the right permissions to the /runtime folder, but still the error messages are not being logged in application.log.
First, I'd double-check that you've configured the logger to log at the appropriate level (e.g. is trace logging enabled?).
Once I did that and confirmed that my settings were correct but logging was still not happening I would then double-check the directory permissions and ownership for protected/runtime. It's terrible practice but you could just set runtime/ to 777 to ensure that it's globally writable. If chmodding it to 777 works then it's a permissions thing and you'll need to sort those out by ensuring that the web server (usually _www/_www on OSX) can write to the directory and that you can read the directory and the files therein.
The way I handle this on localhost is I just add my user to the _www group and chgrp -R _www then chmod g+rwx my Yii directory. This allows both me and apache to have all access.
have you cinfigured logging to file in your main.php:
'components' => array(
'log' => array(
'class' => 'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning, info',
),
),

Resources