2

I try yii framework and for use gii tool - protected folder should have permission 777. In first place i run:

chown myuser:myuser protected;

But i fail to use gii tool soo, i have to run command():

chmod 777 protected;

Is their another way to do it ?(like which user run gii tool that can be joint to the myuser group)

Thanks

1
  • Tangentially, chmod 777 is basically always wrong. 755 should suffice. You should not grant random users write access to your resources.
    – tripleee
    Jan 21, 2012 at 14:41

4 Answers 4

5

Change your protected owner:group using:

$ sudo chown yourUserName:www-data path/to/protected
$ sudo chmod 775 path/to/protected -R

This is what I do and works fine. Try it.

1

Gii tool in Yii creates new files in protected directory. that means apache and php needs to write in protected dir. have you tried with 755. it should work.
The trick is to only use Gii on your development server (localhost) - so that you don't have to reset permissions on your production server.

Edit

Sorry gues, i think i missed something

By default for security reasons, Gii is configured to be accessible only on localhost. If we want to make it accessible on other trustable computers, we can configure the [GiiModule::ipFilters] property as shown in the code below.

return array(
......
'modules'=>array(
    'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'pick up a password here',
        // 'ipFilters'=>array(...a list of IPs...),
        // 'newFileMode'=>0666,
        // 'newDirMode'=>0777,
    ),
),
);

Check Special Topics: Automating code generation for details

0
0

The protected folder as a whole shouldn't need 777 - only the assets and runtime folders.

You can write your own script which just uses the PHP chmod and chown commands.

1
  • 1
    Question is about Gii too which creates CRUD, models, and controllers, so it need to write in respective sub-directories of protected folder. Jan 20, 2012 at 12:28
0

Change ownership of the directories in your project that are subject to code generation.

cd path/to/protected
sudo chgrp www-data models controllers views

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.