Hi, I have an yii2 project built on the app-advanced yii2 template.
I’ve used it only windows without any issue (wamp/apache), and now I’m trying to move it to a linux based setup, using docker, nginx and ubuntu.
The problem I’m facing is that yii2 won’t generate the assets.
If I import the assets from windows, they have different paths, thus why they’re not found (404), if I delete all of them, and either leave the folder or delete the folder altogether, I’d still get 404 and no asset is being generated.
Is there a setting I need to do to get it to work on nginx/ubuntu?
The php code works (login/routes) but no asset works (js/css).
This sounds like a possible permissions issue on the assets folder itself. On your local environment you probably have permissions to do whatever you want (execute/read/write on folders/files) which is why you have never noticed any previous issues. Whereas on your Linux server it probably needs those permissions to be specifically defined depending on how you actually deployed your application.
You will likely need to set the permissions for this user: www-data
You can always open up full permissions on the folder to verify it works, then start locking it down to make it more secure.
There is some information here about Nginx server configuration:
If you delete the assets folder completely it should invoke the same error this person is describing - that’s if the permissions are not set correctly:
If you do not get that error and the folder is re-written along with the asset files then I guess it must be something else, but this is the first thing I would check.
Thanks for the reply.
I’ve tried everything up to setting the entire folder to 777 with recursive flag, and it’s still the same.
I’m not getting the missing assets folder error, and the folder is not being created, I’m just getting 404 on all js/css files and no asset is being imported, it’s like the framework skips entirely the generation step and just does a simple src to see if it’s there.
Also as an update, I’m using docker + gitlabCI.
The deployment goes this way:
At first the init file is executed (777 on assets, 755 on yii) and then I’m building and deploying the docker-compose.
Docker compose has 2 dockers, a nginx one and a php-fpm one. Both have the application folder as a mounting point, so any changes php does, should be propagated in nginx as well.
The application works in term of php, since I can login, and logout, but the asset generation functionality is literally being ignored for some reasons.
Ok, there must be something going on with the way the production environment is set up. There is a historic support ticket discussing something similar here which may be of some assistance:
That assets folder won’t create itself, it will only generate the files contained within it - so you will need to create it if it does not exist, however if it does not exist then Yii should throw an error at least - but you are not even getting that right?
Also, your nginx config is as per this recommended guide right?