WebRoot access permission, Cannot write in /www/var/html

To install WordPress, to update WP themes in ubuntu, to install or update plugins (WP), to install new WP themes in the WEBROOT of local web servers like Apache, you may have faced the following type of problems. Normally web server folder in local Ubuntu installations are located in /var/www/html .

  1. You cannot put WP diretory in Webroot and showing file access problem or permission denied type error when you want to copy/paste using file manager of ubuntu.
  2. You didnot face problem 1 stated above & you have put your wordpress installation folder named WP in /var/www/html/WP . But your browser showing the following errors when you are trying to install WordPress by going to this URL http://localhost/WP
  • To perform the requested action WordPress needs to access your web server, please enter your FTP
  • Forbidden..You don’t have permission to access /wordpress.
  • WordPress Plugin installation in Ubuntu asking for FTP connection

Forbidden screen in Ubuntu localhost

Forbidden screen in Ubuntu localhost, Forbidden , You don’t have permission to access /wordpress-4.3.1/ on this server.


Solution 1 : Change Ownership of /var/www/html (recursively)

  1. If you want to install WordPress in a folder inside Webroot (/var/www/html) or (/srv/www/htdocs/) or some other folder, then your username needs Read & Write permission on WEBROOT.
  2. Normally www-data group has access to webroot folder /var/www/html/
  3. To put your WP folder in webroot add your username to www-data group.
  4. Then put (copy paste) WordPress directory in webroot /var/www/html.
  5. “The user running Apache” also needs Read & Write  permission on that folder /var/www/html/WP/, to install plugins or update & install WordPress (or any other CMS, Shopping Cart or other packages).
  6. Normally www-data user of www-data group runs apache web server in Ubuntu.
  7. So if you are logged in by your username (e.g here diet is my username)  then change ownership of this folder /var/www/html/WP/ to “www-data” user of “www-data” group in Ubuntu which is written in command line this way (www-data:www-data) in (user:group) format.
  8. There exists a www-data user and www-data group in Ubuntu.
  9. In the following example I have shown my username is diet

Know more about Webroot /var/www/html access-

All these are related to file and folder permission, which mainly arises in Linux installations (Ubuntu Opensuse). So we have discussed –

 1) Which user / group is the owner of webroot folder?
 2) Which user/group runs Apache & MySQL servers (to access database)?
 3) As which user you logged in & what permission you have to access those folders and applications?

I am assuming that you have downloaded WordPress package from wordpress.org & you want to install it in Ubuntu local installation or OpenSuse or some other linux installation in your local PC. In your computer you have Ubuntu installed already & also you have installed  Apache PHP MySQL in that Ubuntu machine.

Ubuntu webroot- WordPress installation problem

So first thing you need to do is to copy paste the WP directory you have downloaded from Internet and you want to put it in webroot, in the path /var/www/html/WP/

  • To install WP in Ubuntu you should put the WordPress folder in /var/www/html
  • WP installation directory path /var/www/html/WP/
  • But you are facing the problem – cannot write in /var/www or /var/www/html

When you are facing this problem that means you (your username) donot have sufficient permission in the directory /var/www/html WEBROOT FOLDER to copy/paste, write or modify or create new file/folder in it.

So how to solve this copy paste problem?

  • Add your username to www-data group.
  • Then copy paste the WP directory in Webroot /var/www/html using the file manager.

Know your Username

 diet@linux:~$ who am i
 diet     pts/1        2014-03-27 14:01 (:0)
 diet@linux:~$ whoami

Step 1: add user to www-data group

Add the your username to the group www-data to allow you to write to “/var/www/html”. Mind it you can also permit you (your username) to a specific directory where WordPress is installed under “/var/www/html/” folder , e.g “/var/www/html/WP/” path.

  • In my Ubuntu installation I have logged in using my user name diet.
  • Use the following command to add my username (diet) to the www-data group.
  • www-data is a pre-defined group in Ubuntu.
diet@linux:~$ sudo adduser diet www-data

Confirm that Username  added to www-data group

diet@linux:~$ grep www-data /etc/group
You will see that the following line as output-

Also you can use this command :

diet@linux:~$ cat /etc/group

Now  copy / paste the WordPress installation folder WP in /var/www/html folder & open browser and check whether http://localhost/WP/ is working or not ??

How to check Apache running properly in Ubuntu?

  • Open a web browser , e.g Firefox.
  • Type http://localhost  in the address bar of the browser
  • Then you shall see the content of the folder /var/www/html

Screenshot of http://localhost in Ubuntu 14.04.03 LTS. Apache should be installed

I am assigning my username diet as the owner of /var/www/html by the following command, then opening the WordPress installation folder in Ubuntu localhost…

diet@linux:~$ sudo chown diet:www-data -R /var/www/html

After assigning my username as the site owner I have just copy pasted the WP installation folder (wordpress-4.3.1) inside /var/www/html . Then trying to open it in a browser and found the following screen.

You may face forbidden screen when you are viewing http://localhost/your-folder/ in ubuntu

If you face the above, use the following command in Ubuntu. Make www-data user as the owner of /var/www/html folder.

If you donot know about LINUX file permissions , then please read this page to know more about linux file permissions.

diet@linux:~$ sudo chown www-data:www-data -R /var/www/html
diet@linux:~$ sudo chmod -R g+rw /var/www/html
diet@linux:~$ sudo chmod -R 755 /var/www/html

If you need delete & other high level permission then use the following command instead of last command. Then instead of 755 file permission use 777.

diet@linux:~$ sudo chmod -R 777 /var/www/html

Problem Solved: WP installer running properly

WordPress installation setup Screen in Ubuntu
WordPress installation setup Screen in Ubuntu

Read Some other guide on it.

This is the END of this tutorial, but some other issues stated below if you have faced this kind of problem in Ubuntu.

But try to install any new plugin & you can get this message –

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

Next thing – you must change the folder permission to 755, if you set permission to 777 then the folder will be publicly accessible and a major security hole it will be.

diet@ubuntu:~$ sudo chmod 0755 -R /var/www/test/wp3-8-1/
diet@ubuntu:~$ sudo chmod 0755 -vR /var/www/test/wp3-8-1/
diet@ubuntu:~$ sudo chmod g+s -R /var/www/test/wp3-8-1/

If you are still getting this error – Unable to create directory wp-content/uploads/……/…. Is its parent directory writable by the server, then you can try 777 permission instead of 0755 permission.

diet@ubuntu:~$ sudo chmod 0777 -vR /var/www/test/wp3-8-1/

Probably now you will not face the old error to install the same wordpress plugin in Ubuntu now- Unable to create directory wp-content/uploads/……/…. Is its parent directory writable by the server

But you may have to face some – FTP issues as below

Installing Plugin from uploaded file: plugin-name.zip
Connection Information
To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

If you are the only user or web developer in your linux pc, make yourself as the owner of /var/www/

On many (not all) distributions, “www-data” is the USER under which the Apache web server runs. Apache PHP scripts handling, uploading etc will be done with the permissions of user www-data (and also group www-data) by default.

WordPress uses the user www-data to write files.

Running Webserver Apache2 in OpenSuse

I am using OPENSUSE LINUX here to know the user runs webserver Apache & the owner of Web Server folder /srv/www/htdocs/, I have already installed Apache Web Server and PhpMyAdmin and MySQL already.

bikram@linux-daj2:~> ls -l /srv/www/htdocs/
total 28
-rw-r--r-- 1 root root 302 Mar 13 2006 favicon.ico
drwxr-xr-x 2 root root 4096 Nov 7 2013 gif
-rw-r--r-- 1 root root 45 Jun 12 2007 index.html
-rw-r--r-- 1 root root 2356 Sep 28 2013 info2html.css
drwxr-xr-x 6 root root 4096 Jan 21 12:13 phpMyAdmin
-rw-r--r-- 1 root root 26 May 29 2015 robots.txt
drwxr-xr-x 5 bikram users 4096 Jan 7 00:18 wordpress
bikram@linux-daj2:~> ls -ld /srv/www/htdocs/
drwxrwxrwx 5 root root 4096 Jan 21 13:20 /srv/www/htdocs/
This format shows the name of user and onwer who owns the group:
drwxrwxrwx 5 OWNER GROUP 4096 Jan 21 13:20 /srv/www/htdocs/

The above lines shows user name is : root
Group name is : root

Now I want to know that what user runs apache web server ?
ps -ef | grep apache

So now by this I have seen that APACHE is run by wwwrun user.

BY the following command I shall find out the group number of this user.

bikram@linux-daj2:~> grep wwwrun /etc/passwd
wwwrun:x:30:8:WWW daemon apache:/var/lib/wwwrun:/bin/false

So I found that the user wwwrun‘s group number is :8:

the 4th field (8) is the group number. You can then find the group name with this command
 bikram@linux-daj2:~> grep :8: /etc/group
bikram@linux-daj2:~> sudo chown -R wwwrun:www /srv/www/htdocs/

So in the above we saw that wwwrun USER of www GROUP is now the owner of the whole folder /srv/www/htdocs the webroot of Apache Server running PHP Engine. When I have started to write this article, then root USER of root GROUP was the owner of WEBROOT in OPENSUSE.

wwwrun USER runs APACHE WEB SERVER in OPENSUSE, so I have changed the ownership of this WEBROOT folder /srv/www/htdocs/ from root to wwwrun user, though it is not mandatory. I shall install WORDPRESS Web Server here under this WEBROOT, so you can change ownership of that folder also, in which you shall work.
Visit this Link for more info

WordPress Plugin install asking for FTP

Probably this problem don’t arise in Windows system, but arises in Linux, and I have faced this problem in Ubuntu 12.04.4 LTS. I tried to install demo-data-creator.zip plugin located in my Home folder. I opened the WordPress Dashboard in browser. Gone to-

Admin section -> Plugins -> Add New -> Upload, then click CHOOSE FILE button, click INSTALL NOW.

WordPress Plugin installation in Ubuntu asking for FTP connection info:

When I am trying to install a plugin in WordPress , it is asking for FTP connection information like the following


A solution has been described in this page and visit the above.