Web Process Permissions on Yii / Linux
Asked Answered
S

4

5

I'm a noob and running through a Yii tutorial on AWS. So far I've been able to get everything up and running - including mysql connection. But now I'm using the Gii code generation tool to help create some model classes. In doing so, I'm getting the following error:

generating models/User.php
            Unable to write the file '/var/www/html/blog/protected/models/User.php'.
done!

The documentation also tells me:

Info: Because the code generator needs to save the generated code into files, it is
required that the Web process have the permission to create and modify the corresponding
 files. For simplicity, we may give the Web process the write permission to the whole
 /www/blog directory. Note that this is only needed on development machines when using Gii.

This makes sense to me and I understand the basic logic of Linux permissions as applied to users and groups ... but not processes. Can someone point me to a primer on how to give the Gii process write permissions to the webroot (in my case:/var/www/html/blog/) directory?

Shumway answered 14/7, 2012 at 7:11 Comment(3)
Wanted to add that I've read and understand the danger of running Gii on a production server. However, the ip filter setting in the config/main.php file is set to only allow Gii to be run from my public ip address. So running a live AWS instance (as opposed to WAMP localhost) seems like it would still be safe.Shumway
Further update: I made the mistake of trying a quick fix without properly understanding it and did ... chmod -R 0644 /var/www/html/blog/ ... and I cannot access the page now which means I've shut down the application. ... HELP!!Shumway
set 755. The 'process' doesn't need permissions, the script does, in this case Gii. However, if apache has read/write/execute access (7) on the folders, it should work, granted you add your IP in the Gii config.Toni
H
10

I give all user the priverlege to read, write and excute on the webapp file recursively.

$sudo chmod -R og=rwx webapp_folder

and solved the permission problem, but it may not be the best way.

Hygroscopic answered 14/3, 2013 at 14:41 Comment(3)
It would be better to change the group to the apache group (usually 'www-data' or 'www') and give the group write permissions thereRime
Whatever you are hoping to accomplish, giving everyone write permission is wrong.Encounter
Just give permissions to the directories that are required by Gii. sudo chmod -R og=rwx controllers models viewsDefecate
R
5

Gii uses a process spawned by the webserver user to read and write files. It is this user then that needs permissions to write the file. On Debian/Ubuntu the user is www-data. Check what it is for your OS and give that user write permissions in that folder.

Recuperator answered 14/7, 2012 at 17:11 Comment(1)
As mentioned in the other answer, www-data usually is the group (maybe also the name?) so by making the folder to that group should be enoughRime
W
2

In your httpd.conf file are this lines:

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon

The user and the group of httpd are "daemon". Now in a terminal type the following command:

chown -R daemon:daemon /path/to/htdocs/directory

Sometimes this command must be executed after type

sudo su

Now Gii can write files into protected folder with chmod 775 permissions

Wildebeest answered 1/1, 2015 at 21:22 Comment(0)
P
1

FYI, if command folder or dir created by command like you can write file user browser and same to vice versa... but to access the writing permission for yii..

follow this

sudo chmod -R 0777 your_project_name/
Patterman answered 5/4, 2014 at 5:27 Comment(1)
The text does not make any sense.Palpebrate

© 2022 - 2024 — McMap. All rights reserved.