I have two folders where I can store my website (CentOS VPS):
/var/www/html/index.html
/home/admin/public_html/index.html
I can either store my web application in the first path, but I don't have FTP access to this folder. I can't see it at all when accessing my FTP with the admin account that I received from my service provider.
Or I can use the /home/admin/public_html. For this, I tried to:
change the Root directory in the httpd.conf file;
restart apache;
But this totally does not work!!
It continues to redirect me to the Apache is functioning normally message (from the /var/www/html/ path. why is this happening ?
Even if there is no direct solution, please help me into a direction to get this issue solved so I can continue with my actual work.
At work, I'm using Putty to connect through SSH, at home I use the Mac OSX terminal to access the VPS.
EDIT:
I called my service provider and he mentioned that it's better to leave the default folder (which is var/www/html).
In order to access the file from the client :
I created a link to /var/www from the public_html folder;
Gave permission rights to the www folder recursively;
Connected through SFTP instead of FTP to get access to the folder (normal FTP won't display the folder).
This appears to work rather well.
I suspect Apache doesn't have permission to access /home/admin/public_html. You would need at a minimum to give group read access to /home/admin and /home/admin/public_html to whatever group apache processes run as. Usually it's apache, httpd, or www group--check your /etc/passwd file).
If it's say, the 'apache' group:
chown :apache /home/admin/admin;
chmod g-w /home/admin/admin;
chown -R :apache /home/admin/public_html
If apache must write this directory
chown -R g+w /home/admin/public_html
Then set the group sticky bit (SGID bit) so on any directory from /home/admin/public_html on down (only directories). This will ensure any file created in them will have the same group ownership as the directory. Here's how you do that
find /home/admin/public_html -type d -print | while read i; do SAVEIFS=$IFS; IFS=$(echo -en "\n\b");chmod g+s $i; IFS=$SAVEIFS; done
In case someone else has this issue, have a look at /etc/apache2/sites-enabled
This is where Apache keeps all virtual hosts (This is used to host more than one website on a single ip address.) If you see a 000-default file here, this is usually mapped as the default entry or the site you get when you type in the servers ip address and usually points to /var/www.
PS
Have a look at http://www.virtualmin.com/ It's a opensource cpanel alternative that will provide you with a easy to use web based GUI for common web server related tasks including security, mail, databases and antivirus.
could be selinux related? Look for permission denied in your apache log and have a look in the selinux logs -- /var/log/secure on centos by my memory
Related
I am trying to upload a file through cpanel or wordpress admin panel, but cpanel shows permission denied and wordpress requires ftp access (probably for the same reason). What may be the cause of this?
The public_html directory contains files that were copied from public folder of another server via rsync to /home/somename and then I ran cp command to move these files to public_html. And now, all this is happening. Before cp, there was previous version of website that was working fine.
I'm using Centos 6.3 with Apache
Likely ownership issues.
For Centos 6 the default group for Apache is apache
Go to your webroot, and set the permissions to chown -R apache:apache *
Then make sure to set the permissions 0755
You may be better served by creating a new group and adding both yourself and apache to it. Then assigning the permissions to apache:<your new group>
I am working on a WordPress website from 2 months and I have uploaded many images before but I am getting an error when uploading image and I am facing this issue after new year :- The uploaded file could not be moved to wp-content/uploads/2015/01.
there is Screenshot below:-
This article explains and resolves the issue very well: http://2surge.com/how-to-fix-the-uploaded-file-could-not-be-moved-to-wp-content-error-message
The basic premise is that the identity of the process running your httpd / apache / web server thread must have write access to your upload directory.
To resolve the issue:
Check which account your webserver is running under
Update: On Unix use...
ps aux | egrep '(apache|httpd)'
... this will show a list of processes for the web server along with the identity of the process under which its running e.g."nobody"
nobody 8718 0.1 0.4 1332864 17180 ? Sl 17:11 0:06 /usr/local/apache/bin/httpd -k start -DSSL
Update the permission of the upload directory to allow that account to write to it.
Update: On Unix, you can use...
chown -R nobody /<path to upload directory>/wp-content/upload/
You can also amend permissions for this account (at the rquired location) to ensure it has write permissions using chmod or filezilla and cascade the changes to the directories as necessary.
Check out the linked article for a detailed breakdown. Hope that helps! :)
This works for me.
$ sudo chown -R _www uploads/
$ sudo chmod -R g+w uploads/
I am assuming you are in the wp-content directory.
You just need to give permission to PHP to write in the uploads folder, this worked for me:
sudo chown -R www-data <path>/wp-content/uploads
I have searched and found that the problem is from server provider.
Typically, all files should be owned by your user (ftp) account on your web server, and should be writable by that account. On shared hosts, files should never be owned by the webserver process itself (sometimes this is www, or apache, or nobody user).
Any file that needs write access from WordPress should be owned or group-owned by the user account used by the WordPress (which may be different than the server account). For example, you may have a user account that lets you FTP files back and forth to your server, but your server itself may run using a separate user, in a separate usergroup, such as dhapache or nobody. If WordPress is running as the FTP account, that account needs to have write access, i.e., be the owner of the files, or belong to a group that has write access. In the latter case, that would mean permissions are set more permissively than default (for example, 775 rather than 755 for folders, and 664 instead of 644).
You can see here how to change file permission..
If you're using something with SELinux (like Fedora or CentOS), you'll also need to set SELinux permissions. Assuming that your directory is called uploads (for example)
chcon -R -t httpd_sys_rw_content_t uploads
This will set uploads and everything under it to be uploadable to the web server user
it probably doesn't have the permissions to create
/uploads/2015
Check if that folder exists, if it does, then check
if /uploads/2015/1/ exists.
permissions:
chmod 755 /uploads/2015/1/
chown www-data:www-data /uploads/2015/1/
These folders should have the same permissions as the /uploads/ folder.
Also check the error_log, because it should show you exactly what folder is causing the issue.
This works for me
sudo chown -R www-data html
Assuming current directory is www
Ubuntu 16.04, Apache2
I had this problem as well and found out it was because the hosting account's disk quota was exceeded.
I found that there was an old script that was logging errors and the error log had gotten so big it filled the available quota.
I finally figured it out when I attempted to create a new directory using FTP and the server response was "Disk quota exceeded."
I got this error on a cPanel hosting account, where the disk quota (for the account) was not an issue. After delving into it for a while, I found that cPanel's "Select PHP Version" tool was set to v7.1 but multiple WordPress diagnosis tools were detecting v5.6 was actually running, and they also detected file system issues.
The File Manager tool in cPanel showed all the permissions were correct, and the folders were writeable.
One of the diagnosis tools I used was part of the Wordfence plugin. It was available on the Dashboard menu at Wordfence > Tools > Diagnostics (tab).
I reported the issue to the hosting company, and it appeared to fix itself overnight (the person who responded to my support ticket indicated they didn't fix anything). I think it's likely it was a symptom of a problem that affected multiple hosting accounts, and somebody else within the hosting company probably detected it and fixed it.
In case others encounter a similar issue, I hope this answer helps them spend less time trying to track it down. Once I discovered the incorrect PHP version appeared to be running, I figured it was probably not something I could fix with only cPanel access.
This will happen when you migrate a WP site to a different server.
Problem is the ownership.
Run this in a terminal:
chown -R <site-user-name> /home/<site-directory>/public_html
z
There are multiple reason because of this such error arise.
Main problem is folder permission.
wp-content/upload/
Folder permission must be 775 or 664.
Other solution if the error not get resolved try below
Go to Cpanel and your website folder or by using FTP.
Then you will get wp-config.php {This file available on root folder}
In that do below change
Open the wp-config.php file and add the following code:
define( 'UPLOADS', 'wp-content/uploads' );
before below line
require_once(ABSPATH . 'wp-settings.php');
I hope this will help. It's help me on Plesk Hosting.
This solution is only for those who use the cPanel control panel, and you must test this for other panels like aaPanel, Directadmin and others ...
Be sure to take a snapshot/checkpoint from your server before making changes.
Install the mod_suphp module through Easy Apache.
After installation from the MultiPHP Manager section:
Select suphp from the drop-down menu under the PHP Handler column
And finally, apply the changes.
Test again and if necessary type the following commands:
/usr/local/cpanel/bin/rebuild_phpconf –current
Open you xampp
Click on explore
Double click on folder of your project
Click on "Get Info" in options list
Unlock the locker in the right bottom side by entering your password
Then change permissions to read and write
MOST IMPORTANT POINT, remember to click on the bottom left conner dropdown and select Apply to all
There it will work.
Watch how it is done in this video
Thank me later How to fix xampp permission problem on mac
Changing directory permission to 777 helped me.
I use the plesk panel to upload and download the files from the server , currently the httpdocs folder permission is being set to rwx r-x --- and when i try to access the folder then it does not allows me to access the folder from the FTP as well as from the plesk.
From the plesk though i get an error following error:
Unable to change directory to /httpdocs: filemng: opendir failed: Permission denied
System error 13: Permission denied
i need to change the folder permission for the httpdocs so that i can access the files in it.
i have tried to refer the KB parallel http://kb.sp.parallels.com/en/1528
but was confused in the sense that how could i change the permission. i am using windows PC , please guide me on this , thanks a lot.
I had the same problem, after i tried to install Magento from the Plesk application manager. I searched and got this link http://kb.odin.com/en/124519and did it exactly as the article instructed. domain.tld - it means the particular domain name with its extension, such as .com, .org, .net. Everything worked, in ftp and file manager i was able to access the files and folders.
Resolution
Run the commands below with superuser privileges to download the archived shell script.
Unzip it and execute, providing the needed domain name as an argument:
~# wget http://kb.sp.parallels.com/Attachments/23464/Attachments/recover_plesk_directories.zip
~# unzip recover_plesk_directories.zip
~# sh recover_plesk_directories.sh domain.tld
domain.tld = yourdomainname.com/org/net... whatever, i hope i had been more clear....
For each domain you shall run the command 'sh recover_plesk_directories.sh domain.tld' separately.
Login on server as root via ssh connection and restore default permissions for virtual host directories with help of following command:
/usr/local/psa/bin/repair --restore-vhosts-permissions
I have a PHP script which runs in first server and it curls the PHP file which is on the second server.
$service_url = 'http://example.com/version_check.php?f_path='.$path;
On the second server, that PHP file (version_check.php) reads the files in /var/www directory and processes it.
Now I want to know how to access /var/www directory with root privileges.
I need root privileges because I am doing some fwrites in that directory.
If you’re using the default configuration on Ubuntu, you’ll have a user and group named www-data that your web server runs as. If you want to be able to write to a particular file, chown it to www-data:
$ chown www-data:www-data /var/www/my-file
Alternatively, keep the current ownership, change the group, and make it group-writable:
$ chgrp www-data /var/www/my-file
$ chmod g+w /var/www/my-file
As a last resort if you don’t want to change the ownership or group, make it world-writable:
$ chmod a+w /var/www/my-file
But this is a bad idea—any service on your system, good or bad, can modify the file, rather than just your web server. You should avoid it if you can.
you don't. just make the particular files or folders writable by www-data. running your PHP script as root would be a serious security problem. even more so, because I don't expect you to follow any common security guidelines (if you did, you wouldn't want to run your script as root).
Kumaran,
The issue isn't PHP; the issue is the user accessing the files. Your PHP scripts are run by the apache user (www-data or apache, you'd need to check the username your apache's running under). The apache user, by default, can access certain files.
To be able to access files using root privileges, the apache user needs to acquire the rights to do so.
Allowing this to happen is a big security risk. You need to re-think the architecture altogether; why is PHP accessing root files in the first place?
One option is to make the files in question writeable by the apache user
The /root is only readable to root user. Hence you need to first move that Move file to /var/www and change it's permissions so www-data users can read it.
I'm using Apache 2 in Linux mint and I don't know where to store my files and projects. if I store it in var/www it is not accessible for me, I have to use command as super user. Are there any way to solve my problem?
- If I want to store in my home folder, what should I type in the address bar if I want to run my file?
- Are there any other good solution than these? (such as change the accessible to folder /var, or change the Root_Url of apache ...)
The easiest way to solve this provlem is by typing the following line in terminal:
sudo chmod -R 777 /var/www
and then enter your password. And now you are done. You can store all the PHP files in /var/www
You have to do a chmod, you can have more information in your terminal with comand man chmod to set the rights to write in that folder or else point the web-server elsewhere (the setting is in the https.conf file)
There is different solutions:
create a symlink from /var/www/link to your projet and set your project
create a virtualhost with the DocumentRoot to point to your project: http://httpd.apache.org/docs/2.2/vhosts/examples.html
in both cases your project must have gives permissions to the apache user (www-data?) to read/execute you project
You need to active the user_dir mod of apache and then run the content from your home folder.
To run a file in your hole directory you should go to localhost/~youruser/script.php of course after enabling user_dir
Everything depends on the use.
If you are looking for a configuration for a development server that is accessible only from limited host (such as localhost):
You can configure Apache (/etc/apache2/apache2.conf) to run with your user/group.
User myuser
Group mygroup
Store all your project in your user_dir (/home/myuser/projects/...)
Create a virtual host for any of your projects
All files generated by your server will be accessible to you and vice versa
One way to accomplish this is to edit the default virtualhost supplied with Apache 2. In Linux Mint 14 its configuration file is located at:
/etc/apache2/sites-enabled/
This directory should hold symlinks for all active sites, for me the default is named 000-default.
Change the lines with "DocumentRoot" and "Directory" to point wherever you like. The server should have read only privileges by default. If you are working on file manipulation then it will need permission to read and write files.
Once this is set, restart the server ("sudo service apache2 restart") and type localhost in your browser to access the directory you've set above.
For more advanced configs have a look at:
http://community.linuxmint.com/tutorial/view/853
http://community.linuxmint.com/tutorial/view/527