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?
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.
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.
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
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With