Permission usert Tomcat7 for send files to apache2 folder (httpdocs) - php

UPDATE 28/07/2016
Help me please.
My problem is I have a ubuntu server with the following configuration
In summary ::
my internal server (tomcat 7) .war owner user does not have permission to create, modify, ... folders, upload files (but yes, to read all this).
my module in plesk is apache (is not whether it would be better, CGI, or FAST-CGI).
I've tried everything, changed owners folders permissions for adding groups, more users, I modified mod_jk, I changed server.conf, worker.properties, tomcat.users, catalina.policy, ........
And I can not get the user and owner (tomcat7) .war, achieve create, modify, delete folders, upload files etc ...
However from the local tomcat, which makes the request when the user is www-data, you can do all.
can someone please help me with some idea?Thanks.

I finally had to switch to a windows server because of problems with plesk and ubuntu.
and voila, everything working properly

Related

Can't view re-uploaded php web files in my Linux server

I used to have a Windows OS server where i uploaded some old php web files to it. I could then access them, edit them, and view them online via my host name.
After much debating and reasoning, we had to change the OS of the server from Windows to Linux. After the change had been completed, a backup of the server was uploaded to the new Linux installation where all my old files were kept.
I could view these files online as I used to do when the server had windows OS.
The only thing I did encounter was the following:
a) I downloaded my files from the server using putty,
b) I deleted the old copy in my Linux server,
c) I then re-uploaded the same file that used to be in the server without making absolutely no change whatsoever to it, to the exact place where it was,
d) When I try to access it via its web address like I did earlier, it throws an error message saying..."The page isn't working".
I don't know much about Linux and there fore I am stuck. I don't know what the problem is. I can't understand why I can view all the files via their web address if they were placed there from the backup, but when I download them, delete their file from the server and then re-upload the exact same downloaded file to the exact place where it used to work, I get an error message.
Extra info: I connect to this Linux server from a windows OS machine using putty.
I found the problem. Since I migrated from a Windows OS server to a Linux Cent OS server, I didn't know that you had to configure the privileges of each folder in order to be accessed from the web. By default, my uploaded files where tagged by ownership of "user". The server was configured to only display files that were tagged by ownership of "root". The way I solved this was by typing the following command in the terminal.
NOTE: "You have to be in the folder where the file you are going to change ownership is."
sudo chown root:root filename.php
sudo -> Execute in admin mode
chown -> Change ownership of file to...
root:root -> ... root instead of user
filename.php -> the name of my file
Executing this corrected the error. Hope it helps someone else since I coudn't find anything related.

Yii - Application runtime path "{path}" is not valid. Please make sure it is a directory writable by the Web server process

I'm very new to Yii, so please bear with me. I've an existing XAMPP setup on my MacBook, and an existing project I need to take a look at. At first the project was looking for a yii.php, so I downloaded the appropriate version (1.1.17), and extracted that to /htdocs/.
I renamed it to yii, and set the yii directory in my index.php to:
$yii=dirname(__FILE__).'/../../yii/framework/yii.php';
For reference, the project has the following directory: htdocs/cdforum/web/index.php
With everything in place, or so I think, I started up XAMPP, and loaded http://localhost/cdforum/web/index.php only to encounter the following error:
throw new CException(Yii::t('yii','Application runtime path "{path}"
is not valid. Please make sure it is a directory writable by the Web
server process.'
I have seen some people get past this by setting the yii folder's ownership via chown to their own, or apache, but the first option didn't work for me, and apache apparently is an illegal user name.
Anything else I can try?
Change your username:group in httpd.conf file of Apache:
About line ~181-182:
To your user in your Mac.
Don't change the Apache User and Group. There are very good reasons why Apache has it's own user and group. Here's a simple example of what can go wrong...
While developing you make a mistake in your app and delete files
recursively in a directory, this directory has a sym link that you
follow into your home directory and you delete everything in your home
directory. This cannot happen if the users are different.
In production if you changed the owner of the user/group to a real user account the you'd almost certainly incur the wrath of the OPS department ie you're creating a security hole, a bad one.
The correct thing to do is to do what it asks ie make the directory writable by the apache process ie use chown or chmod. If you are developing then use this, in production this is also bad...
chmod 777 ./path/to/directory
In prod the directories apache need to write to would either have group write permissions for the apache user or be be owned by the apache user. Only those directories that it requires write access to, nothing else.

The uploaded file could not be moved to wp-content/uploads/2015/01. issue on image upload

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.

What are the configurations required for Apache (HTTPD) for enabling directory/file writing and file uploading?

Hie,
I have installed a new httpd server and loaded my web application on it which is designed to upload files on the server. Also it creates new directories and files inside the web directory of the application. But i am unable to use these features because it gives me a permission denied error. I searched onto the web and got the clue that i require to enable ftp login through my PHP script. I changed the ownership and permissions but it is still not working. Can please someone explain the configuration required in simple steps to enable these features. I am using CentOs-6. It will be highly appreciated. Sorry for the miss formed question.
Configurations I tried out:
Create a Linux user and group named webuser. Give it permissions of
the directory of my web applications. Install Vsftpd and allow webuser
to login. Set webuser FTP root directory same as my Web Application
directory (i.e /var/www/mysite)
My httpd user is apache.
I was doing everything right. The only problem was CentOS SELinux. It was not allowing apache to write files into the web directory.
Using the command "setenforce 0" , i closed it down and everything started working.
Later, I added an exception into my SELinux policies to fix issues.

File permissions for CodeIgniter on Ubuntu web server

I have a CodeIgniter app running in production on Apache 2.2 with PHP 5.3 on Ubuntu 11.10. I am also running PHP5-APC, if that matters. So the app runs as www-data:www-data per the default Apache2 install.
I am trying to figure out what to set my file permission to. Many threads on SO seem to prefer 755 for directories and 644 for files. There is one directory that must allow files to be uploaded to it.
Currently my deployment script does something like this:
wipe old site
copy new site over
chmod -R 000 on the new site
chmod all directories to 500
chmod all files to 400
chmod 700 on the upload directory
Everything seems to work fine. I can upload files and so on.. so, I don't understand why people suggest 644 for files - I have a config file that has passwords and API keys - why would I want 'others' to have read-access to it?
What am I misunderstanding?
Well, mainly the 644 permission is meant for when you have /var/www/site1.com with different user and group set then www-data, because then the 644 would allow other groups and users to read from that file, but will allow to read and write the owner of the file.
As by default the user that uploads files and runs apache's processes is www-data then I honestly think that if it works for you and you have no issues, it's great because means a little more security.
Update
Just a small security issue, is that www-data has become a very common user and group for http services to run their processes. I would much recommend that each site/app have their own user and group.
*44 and *55 just means that the file/folder is readable by others.
This would be good if say, you uploaded files to the web server but they for some reason were owned by someone else (say your own login account), then apache could still read them and it'd be "no fuss". Or if you needed multiple groups to be able to access the files.
If you know you are uploading the files as the apache user, and apache (or whichever programs run under www-data) are all you need to be able to read/write the files, then *00 is completely fine. It can even be argued that it's a little more secure.
For people who don't know what they're doing on the linux command line, 644 and 755 are about the right mix between "convenient" and "safe" (completely debatable, though), so they are what is recommended for a quick fix.
When doing shared hosting, you have user accounts that upload php files via FTP. So, when user "joe" uploads his .php file, it is owned by "joe" and when Apache needs to read it to execute the script, it cannot. Users are usually in "users" group, so even giving privilege to the group would not be enough. That's why you need to give privilege to everyone, so that user "www-data" can read the file uploaded by "joe".
If you run your own server, than of course, you have full control and none of this matters.

Categories