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
Related
So , I am working on a small project where I need to create a symlink to store file in the storage directory in laravel. I was previously working on windows where the same code was working fine but as I configured Laravel Sail and set it up in my WSL-2 environment, I performed my ritualistic tasks of setting up the config, creating symbolic link, I am noticing a weird behavior of running the php artisan storage:link command where it creates a file instead of a folder in my app/public folder.
It should be a clickable folder or if not clickable, atleast my IDE should show it as a directory like that of others, i.e. like public, bootstrap, database folders. Is that a problem with my WSL or some internal configuration of Laravel. On double clicking this link it shows:
Any assistance will be greatly appreciated.
If you created it in wsl2, windows won't regonize it as a symlink, it's a unix symlink and not a windows "symlink" that's all.
In WSL you're working inside a unix based filesystem and sharing your filesystem with windows.
Its because your file its just accessible in the docker container created by sail. You cant access to it like this.
note: this is not an error or missing. it is just a behavior
In my case the happened in Ubuntu since I had to connect my storage/app/public folder to public/storage. at first glance, I was confused, and seemed to be an error but with some more try and fail it was correct as it is. the problem was, in Windows all our files existed in a symlink to the public/storage folder and from there we could delete and manipulate the file but after creating the file symlink all files are only visible in storage/app/public directory but can access from public/storage folder from the web easily.
As a work around, created folder manually and run the command.
sail php artisan storage:link.
It will link
I'm working on Laravel 5.6 and I downloaded code from the server and set it up successfully in localhost.
If run cmd php artisan serve then it works correctly but when I open the browser and type localhost:8000 or 127.0.0.1:8000 and open my project in the browser, then the browser buffers the page infinitely.
Give permission to storage folder
Generate key using php artisan generate:key
Make sure you have .env file in root folder
Check for HTACCESS redirection
Check database connection ( setup correctly )
Still getting issue then provide more details like screen-shot etc.
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.
I have developed a laravel project in laravel 5.4 on xampp localhost.
as on localhost I ued php artisan storage:link to link storage/app/public/images with public/storage to access images. So its working 100% correctly on local host but when I uploaded it on hosting server I lost access to those images. I dont know how can I fix it. please some one help me to make it working.
First delete the shortcut created from localhost (if you have uploaded it to server).
Create a blank php file (like link.php), paste the code below to it:
<?php
symlink('/home/**domain**/storage/app/public', '/home/**domain**/public_html/tests/storage');
In the above code, don't forget to replace domain with the name of the root folder of your domain.
Then upload the file to your public folder (like public_html).
Then on your browser search for your_domain_name/link.php
Hope it will work
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.