I have this problem in most of my yii2 projects. I got this error:
copy(/var/www/vhosts/gunungkombengtetapselalujaya.com/httpdocs/frontend/web/assets/56687de2/yii.activeForm.js): failed to open stream: Success
I have contacted my hosting provider but they didn’t give me any solutions at all so I’m at lost. I have tried to delete all folder in frontend/web/assets but the newly generated one still give this error. I search inside those newly generated folders and some files are not available, like yii.js and others, which might caused error mentioned above. It’s as if frontend/web/assets is not writeable, but I checked the file permission and it’s already 755.
this is my configuration for assetmanager
'linkAssets' => false,
'bundles' => [
'yiiwebJqueryAsset' => [
'jsOptions' => [ 'position' => yiiwebView::POS_HEAD ],
],
],
'forceCopy' => true,
What could be the problem? It’s still ok yesterday, but early this morning this happens. Please help.
UPDATE
I change linkAssets to true:
'linkAssets' => true,
'bundles' => [
'yiiwebJqueryAsset' => [
'jsOptions' => [ 'position' => yiiwebView::POS_HEAD ],
],
],
'forceCopy' => true,
It can be opened, but the files in newly generated folder are having 403 error when I access them.
2
Answers
I suppose that PHP is running as another user. That’s why it has no permission to write files to this folder.
Try to set the permissions to 0777.
As @schmauch said this is file permission and yes this may cause the file permissions, you can check in more details below –
Check File Permissions: Ensure that the destination directory and the file you’re trying to copy have the necessary write permissions. You can use the chmod command to adjust permissions if needed.
chmod 777 /var/www/vhosts/gunungkombengtetapselalujaya.com/httpdocs/frontend/web/assets
Be cautious with setting permissions to 777, as it grants full read, write, and execute permissions to everyone. It’s recommended to use the minimal permissions necessary for security reasons.
Double-check if the file you’re trying to copy (yii.activeForm.js) already exists in the destination directory. If it does, consider deleting it or renaming it to avoid conflicts.
You can also check the file owner permissions here is command
chown www-data:www-data /var/www/vhosts/gunungkombengtetapselalujaya.com/httpdocs/frontend/web/assets
One other know is the space on the server, check if you have enough space on the server
I hope you will get the solution.
cheers