问题
I created a new subdomain and uploaded the WAR file into its directory, but the server returns following error.
java.io.IOException: Unable to create the directory[/home/jack/public_html/WAR/MYWAR]
.....
The permission of WAR folder and the WAR file are 0755.
drwxr-xr-x 4 jack jack 4096 Feb 2 02:43 ./
drwxr-xr-x 10 jack nobody 4096 Jan 25 01:48 ../
drwxr-xr-x 2 jack jack 4096 Jan 24 22:38 cgi-bin/
-rwxr-xr-x 1 jack jack 82135738 Feb 2 02:23 MYWAR.war*
drwxr-xr-x 4 jack jack 4096 Jan 25 01:31 WEB-INF/
ps -aux | grep tomcat
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 1239 0.0 0.0 103240 864 pts/2 S+ 04:38 0:00 grep tomcat
root 1330 0.0 0.0 10436 352 ? Ss Feb01 0:00 jsvc.exec -user tomcat -cp ./bootstrap.jar -Djava.endorsed.dirs=../common/endorsed -outfile ../logs/catalina.out -errfile ../logs/catalina.err -verbose org.apache.catalina.startup.Bootstrap start
tomcat 1334 0.2 14.9 1566688 151852 ? Sl Feb01 1:38 jsvc.exec -user tomcat -cp ./bootstrap.jar -Djava.endorsed.dirs=../common/endorsed -outfile ../logs/catalina.out -errfile ../logs/catalina.err -verbose org.apache.catalina.startup.Bootstrap start
回答1:
0755 is rwxr-xr-x. If you are not the owner of the directory(it is usally user nobody), you cannot write in the directory. You need to be owner of the directory or root to write in that location.
回答2:
try:
sudo chown -R tomcat:tomcat /home/jack/public_html/
probably you shouldn't need to change for the entire public_html
, but you can try to see if it works, and then restrict permissions to your desired folder.
回答3:
We need to make sure that Tomcat has permission to fully access the folders. Firstly identify what user or group Tomcat is running in. Next grant that user and/or group ownership. For example the following code will change ownership of directory test folder and everything under it:
sudo chown -R owner:group /home/blabla/test
This will give the owner and group ownership for executing commands. http://www.computerhope.com/unix/uchown.htm
Next we use chmod to grant permission which defines the permissions for the owner of the file (the "user"), members of the group who owns the file (the "group")
http://www.computerhope.com/unix/uchmod.htm
回答4:
seems like you need to
give group full access write to the WAR directory
sudo chmod 775 /home/jack/public_html/WAR/
then change the group of the directory to tomcat
chown -R jack:tomcat /home/jack/public_html/WAR/
回答5:
If permission, user and group are correct. Maybe the answer is selinux.
来源:https://stackoverflow.com/questions/28271111/unable-to-create-the-directory-error