CakePHP chmod question - php

I downloaded CakePHP and put it in my www directory. I enabled mod-rewrite and all that and changed my document root. But I still get permission denied errors in my apache error log because Cake can't require the files from other directories. It's almost as if I need to chmod every single directory to 777 in order to make this work. I know that's not right but can someone tell me if I did not install it correctly or what to CHMOD. Because so far it's literally every folder I'm going through CHMODing right now.

Try
chown -R <webserver_user> <cake_dir> #set the owner of your cake dir recursively to your webserver
chmod -R 755 <cake_dir> #set the permissions recursively
you can get the webserver user with
ps -aux | grep apache #or whatever your web server is

Related

Laravel root permission messed up

I have this Laravel project on my Ubuntu machine, and i accidentally gave chmod -R 777 to Ubuntu root. I did manage to cancel it, but it was to late. Now, like half of my root is green.
I have nothing useful on this machine except that Laravel project, and I have no problem with re-installing it. Is there a way to rebuild it? If not, when i backup my project, how to give it normal permission?
I've been through this before
Just run
sudo chmod 0644 -R * in your application's root directory
it will set the default permission level to -rw-r--r-- (0644). As new laravel application comes with this permission level.
and you need to give write permission to storage folder and its files so run
sudo chmod 0755 storage and sudo chmod 0755 storage/* -R
You are good to go now. and for more about file and its permission level, I would recommend you to go through this https://askubuntu.com/questions/638796/what-is-meaning-of-755-permissions-in-samba-share it will help.
When you reinstall the project it will gain the regular permissions. Remember that you only have to give 777 permissions to the "storage" folder.
And as far as I know, there is no way to set your Ubuntu files as they were before.
Just change and update permissions of public/ folder inside your Laravel app/ folder to 0775, and then change permissions of files inside public_html/ folder to 0644. Also what is worth of noticing is user:group. What server and how do you run PHP handler?

How to set root access for all files put inside my Apache2 root directory?

I am learning PHP at the moment on Linux. I have an Apache2 server running locally. Whenever I tried to save a PHP file into the root directory of Apache2 server ( /var/www/html/), I was told that permission denined.
So, I searched around and found that by default, the admininstartor do not have the root access unless explicitly request for it (like sudo su). I have also seen some posts which ask me to use gksu nautilus. However, my linux 14.04 LTS Ubuntu doesn't comes with it. (I know I can use apt-get gksu but at the moment, downloading it from internet is not an option).
Is there anyway that I can change the permission to my Apache2 server root directoy so that I can use any text editor to save/edit to that directory directly. Only the ways that do not need downloading stuffs from internet are feasiable for me at the moment.
For linux open the terminal with root login then go to the root folder and run the following command chmod 777 following is the example :-
To change all the directories to 777 (-rwxr-rwxr-rwxr):
find /opt/lampp/htdocs -type d -exec chmod 777 {} \;
To change all the files to 644 (-rwxr-rwxr--rwxr--):
find /opt/lampp/htdocs -type f -exec chmod 777 {} \;
If this will not work then try the following :-
Create a new group
groupadd webadmin
Add your users to the group
usermod -a -G webadmin user1
usermod -a -G webadmin user2
Change ownership of the sites directory
chown root:webadmin /var/www/html/
Change permissions of the sites directory
chmod 2775 /var/www/html/ -R
Now anybody can read the files (including the apache user) but only root and webadmin can modify their contents.
Hope this will help you in solving your problem.
You can set the DocumentRoot in your /etc/apache2/httpd.conf file to a place where Apache has write access. For example, you could set it to /tmp/www if you made a directory there. (If you still don't have access, you can always give everyone read access by running chmod a+r /tmp/www, but you should probably be fine.)
Obviously leaving your Apache Document Root as /tmp/www is a bad idea, so you can change it to something like /home/chris once you've got it working.
One important note: after you make a change like this, you must restart the Apache server. This can be done by running apachectl restart; ironically, you might have to have administrator rights in order to execute this (or even edit the config file in the first place), so make sure you prefix your edit & restart with sudo just in case.

Unable to create directory wp-content/uploads/2014/07. Is its parent directory writable by the server?

Hi anyone can help me for this issue , I have developed a site and it is hosted on my development server but now my client wants to move it to his own production server, and my client doesn't have access to his cpanel for this server. I only have the ftp access, so I have added his database in my own development server, while in development I used my amazon s3 for storing the images , when I push to production I loss the amazon plugin . I can't able to install the plugin , so I moved to upload once again to those images through WordPress, now I face this error while uploading an image : Unable to create directory wp-content/uploads/2014/07. Is its parent directory writable by the server? , and change the ftp file permission access to 755 and changed the uploads file permission to 777 , Still I am not able to upload the images, can some one help me for this issue.
This is a problem of the Apache permissions. I had this problem and i broke my mind for many days to understand what was happening.
The correct way (USE IT):
(the solution that i used, and worked)
You need to give Rewrite permissions to the Apache.
For Ubuntu:
Run via ssh: chown -R www-data:www-data /var/www/the/wordpress/directory
For Centos:
Run via ssh: chown -R apache.apache /var/www/the/wordpress/directory
The Wrong Way (I don't recommend it, but works...)
You can change the permissions to 777 in all the paths that Wordpress need to change. wp-content/plugins recursively on folders to solve install/update problems, and wp-content/uploads recursively on folders to solve upload media problems.
Never use it because you are giving permissions to anyone change your files. A open way for the crackers that don't like you.
run these command to provide proper file permissions
Add existing 'ubuntu' user to 'www-data' group
sudo usermod -a -G www-data ubuntu;
Set the ownership of the files/directories
sudo chown -R www-data:www-data /var/www/html/;
Set group ownership inheritance
sudo chmod g+s /var/www/html/;
Set the permissions of the files/directories
sudo find /var/www/html/ -type d -exec chmod 755 {} ;
sudo find /var/www/html/ -type f -exec chmod 644 {} ;
Give write permissions to the group (for editing files via FTP)
sudo chmod -R g+w /var/www/html/;

Allow creation of folder on apache2 in Ubuntu Server

I'm creating a site which I'm going to host on an Ubuntu Server. I have a user registration form on my site, which creates a user and a folder for that user (if filled out correctly). The form in handled by PHP and I'm running Apache 2 on the server. When I run the code on my laptop the folder is created, but when I run the same code on the server the folder is not there. I guess that it has something to do with permisssion. How can I tell apache that the code should have write permission in a specific folder called "users" located in /var/www/mysite/public/users/ ???
Try using chmod command that provides folder permission. Something like
chmod 777 -R foldername
If security is not an issue I would suggest:
chmod 775 -R /var/www/
chown -R [your_user]:www-data /var/www/
So both apache2 (www-data) and you can edit folders and files inside /var/www (or /var/www/html if this is your folder).
Notice that this may have issues with git and other tools that capture folder permissions (eg with git you may commit files with 775).

Configuring Codeigniter framework on Linux

I've installed Codeigniter on Linux CentOS.
I extracted everything to my web directory, set everything up, and everything worked fine.
Next I moved my application/ and system/ folders outside the web directory, and then provide full path to them in index.php. The folders I provided resolve fine from the command line, but I continue to get the error:
Your application folder path does not appear to be set correctly. Please open the following file and correct this: index.php
Here are the full path locations:
$system_path = '/data/utilities/codeigniter/system/';
$application_folder = '/data/utilities/codeigniter/application/';
First, is utilitities a typo only here, or in your index.php, too?
Second, does Apache have full access to /data, utilities, and codeigniter?
What are the permissions of the folders? The Apache user might not have access to those folders. You can find out the permission by using the command ls -la and then set the owner or group to the Apache user chown www-data:www-data -R /data/utilitities/codeigniter/system/
and chown www-data:www-data -R /data/utilities/codeigniter/application/ (Assuming that the Apache user is www-data).
Permissions were not set correctly... silly mistake. I did this to fix it:
sudo chmod -R 755 /data/utilities/codeigniter/

Categories