Does exist way to use gii tool without make protected directory permission 777?

1.8k views Asked by At

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

4

There are 4 answers

0
Uday Sawant On

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

1
Dan Blows On

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.

0
sdlins On

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.

0
Xavier John On

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