I deployed my Laravel 5 app (empty initial app) to Heroku using Github repository and it keeps producing exception
production.ERROR: ErrorException: file_put_contents(/8a232580639f5a7a06b1d497d0825c281c17c91d.php): failed to open stream: Read-only file system in /app/bootstrap/cache/compiled.php:7198
Why would it even try to create a file in the root / directory?
The interesting thing is if I create a new Laravel application and deploy it using Heroku's Git (vs Github repo) it works without problems.
Make sure storage/ path is not ignored. Instead of ignoring the whole storage/ path, replace it with the following in your .gitignore. This can be improved on what are the files and directories that will be created under storage, I haven't much done laravel/lumen in a while so I'm not so sure. But this are the basic ones.
storage/app/*.php
storage/framework/*/*.php
Related
I am trying to access my image files stored inside storage/app/public/subfolder/ using symlink inside /public folder in my Laravel app. Everything works fine in my local setup and also in Jelastic Apache deployment, but it doesn't seem to work in CPanel with LiteSpeed. I am trying to access the files using the link /storage/subfolder/image.png but it is not accessible on CPanel deployment.
I tried creating and deleting storage symlink hundreds of times, but it didn't work. Below are few things I tried:
Deleting and creating symlink again and again using php artisan storage:link command.
Creating symlink using linux command ln -s ../storage/app/public storage inside public folder.
Running Artisan::call('storage:link') using a web route entry.
Redeploying and reconfiguring the app several times and creating storage symlink.
In all of these failed attempts I can verify that storage symlink is created every time inside public folder. I can navigate and view files from public/storage/ folder using CPanel terminal without any issues but can't access them in the deployed app.
I have exact same configuration in Jelastic Apache deployment and in my local deployment and there it is working without any issues.
UPDATE:
Additionally, I tried creating a storage directly manually inside public folder with the same structure and it worked. But symlink doesn't work.
UPDATE 2:
I found below error log while checking error logs from CPanel.
2022-11-06 05:07:07.342556 [ERROR] [1669834] [T0] [HTAccess] Failed to open [/home/user/my-project/public/storage/subfolder/.htaccess]: Permission denied
There is no .htaccess inside subfolder but it is there in my public folder.
What might be the issue?
After making linking you storage to your public path using storage:link you can access your folder :
'Storage_path('subfolder/image.png');'
After a long search, I finally found the cause.
Somehow the storage/app/public directory didn't have sufficient permissions. So, I gave permissions to that public folder recursively using chmod and everything works fine now.
The symlink was working fine but it was not working due to permission issues in the parent folder.
This is a bit weird as I have never manually altered permissions in any Laravel folders in any of my other deployments.
So I am using Laravel Homestead for my local development. I opted to install it per-project rather than globally so that all of my Homestead configuration files would be tracked in my git repository. To keep my repository clean, I opted to place the entirety of the Laravel application into a sub-directory named 'code'.
This, however, has presented me with a challenge when attempting to deploy my application via Envoyer. It seems as though Envoyer assumes the Laravel application files are in the root directory of the repository. As such, when it attempts to deploy it fails.
I've been searching around and can't seem to find any way of specifying to Envoyer that my Laravel application files are not in the root directory of the repository but are in the 'code' directory. Any help would be greatly appreciated!
Repository Structure:
/
- Homestead related files
- /code
- Laravel application files
I am trying to deploy my WordPress site from local to staging. I'm able to deploy the files up to my hosting site but now I'm getting an error in Chrome when I'm trying to access my site http://staging.responsivhub.com/
After uploading my site to my webserver "siteground" in public_html/staging and have changed my subdomains root location to public_html/staging/current/web. After that I'm getting this error
Warning:
require_once(/home/user/public_html/staging/releases/1/vendor/autoload.php):
failed to open stream: No such file or directory in
/home/user/public_html/staging/releases/1/web/wp-config.php on line 7
Fatal error: require_once(): Failed opening required
'/home/user/public_html/staging/releases/1/vendor/autoload.php'
(include_path='.:/usr/local/php71/pear') in
/home/user/public_html/staging/releases/1/web/wp-config.php on line 7
(I have replaced my username to user)
I can't figure out what I'm missing.
You need to create the web/wp-config.php files inside the shared folder with the database credentials and all the WordPress configuration.
Go to (with the webserver/deploy user):
mkdir /home/user/public_html/staging/shared/web
vim /home/user/public_html/staging/shared/web/wp-config.php
And then include the configuration inside that file. After that try to re-run the deploy. I'm not sure if the wp-config.php file is on the root folder so you can try to remove web/ folder when running the commands.
I have this website. The problem I have is
The freelancer-ngohungphuc.rhcloud.com page isn’t working
freelancer-ngohungphuc.rhcloud.com is currently unable to handle this
request.
500
I develop this website using Laravel 5.1. So what I have to do to fix this error.
Although you can usually check logs to see why you are getting a 500 error, it would appear that this is due to insufficient permissions - which need to be set on the storage and bootstrap/cache folders (as per the docs).
The folders both need to be writeable by your web server, so whilst 777 permissions will definitely work 775 should be fine (and more secure).
Doing this via a command line can be done with the following command (run it with sudo if you need to elevate to root permissions) chomd 777 -R storage bootstrap/cache or chomd 775 -R storage bootstrap/cache.
Doing this via an FTP client is doable, generally speaking you can just right click on the folder and choosing to edit permissions from there.
In some instances, vendor may need to be done too - from my experiences anyway.
These folders are all inside the root project directory for your Laravel application.
Edit
Excerpt from bottom of error log:
PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE)
This would indicate that the PHP version you are running is not >= 5.5.9 (one of the Laravel requirements).
This is confirmed in the screenshot shown of the OpenShift configuration. The version of PHP needs to be updated for Laravel to work - this wasn't just a permission issue.
My heroku slug size is 389mb, so push is rejected. Now the Point is, if i deploy my same application on new domain (by using heroku create again), the slug size, i am seeing is just 200mb.. Why its different? Then I have tried this approach:
Approach 1: by deleting .git folder from my project directory, then again git init. and then deploying again on same heroku app.. It didn't make any differences!
Approach 2: By declaring .slugignore file in root of project folder. But its too not making any diff!
Approach 3: as per this site, https://github.com/heroku/heroku-repo
I have reset my repo like this,
heroku repo:reset -a appname
But, nothing happened!! What to do now? Can u guide me? Thnx.
As Heroku suggests:
Inspect your slug with heroku run bash and by using commands such as ls and du
Move large assets like PDFs or audio files to asset storage
Remove unneeded dependencies and exclude unnecessary files via .slugignore
Hey I was able to find the solution. Here is what i have done:
I have downloed Heroku Repo plugin from this site :https://github.com/heroku/heroku-repo just by this line:
heroku plugins:install https://github.com/heroku/heroku-repo.git
then I have just rebuilt my app by this command:
heroku repo:rebuild -a appname
This will empty the remote repository and push the repository up again, effectively triggering an app rebuild. and I got whole working app with original downsized (207mb) again. that's it.