I have installed Wordpress on my local Ubuntu machine, with standard LAMP configuration and phpMyAdmin. The installation directory is localhost:///var/www/blog.

At the second step of the installation, after I've entered the MySQL configuration, the following message appeared:

Sorry, but I can’t write the wp-config.php file.

Current permissions are:

-rw-r--r-- 1 adam adam 2.0K Oct 23  2010 wp-links-opml.php
-rw-r--r-- 1 adam adam 3.2K Nov  1  2010 wp-config-sample.php
-rw-r--r-- 1 adam adam 3.7K Jan  8  2012 wp-trackback.php
-rw-r--r-- 1 adam adam  271 Jan  8  2012 wp-blog-header.php
-rw-r--r-- 1 adam adam  395 Jan  8  2012 index.php
-rw-r--r-- 1 adam adam 3.5K Apr 10  2012 wp-comments-post.php
-rw-r--r-- 1 adam adam  20K May  6  2012 license.txt
-rw-r--r-- 1 adam adam  18K Sep 11  2012 wp-signup.php
-rw-r--r-- 1 adam adam 2.7K Sep 11  2012 xmlrpc.php
-rw-r--r-- 1 adam adam 2.7K Sep 23  2012 wp-cron.php
-rw-r--r-- 1 adam adam 7.6K Sep 25  2012 wp-mail.php
-rw-r--r-- 1 adam adam 2.4K Oct 26 21:40 wp-load.php
-rw-r--r-- 1 adam adam 4.6K Nov 17 17:11 wp-activate.php
-rw-r--r-- 1 adam adam 9.7K Nov 22 11:52 wp-settings.php
-rw-r--r-- 1 adam adam  29K Nov 30 15:40 wp-login.php
-rw-r--r-- 1 adam adam 9.0K Jan 24 22:50 readme.html
drwxr-xr-x 9 adam adam 4.0K Jan 24 22:53 wp-includes
drwxr-xr-x 4 adam adam 4.0K Jan 24 22:53 wp-content
drwxr-xr-x 9 adam adam 4.0K Jan 24 22:53 wp-admin
drwxr-xr-x 4 root root 4.0K Apr  1 14:52 ..
drwxr-xr-x 5 adam adam 4.0K Apr  1 14:55 .

I've added a+w permissions to the blog folder:

chmod a+w 

And now everything works, but I don't know if it's safe to grant global write permissions to that folder.

Which file and directory permissions should I set on a new Wordpress/LAMP installation?

5 Answers 5


Which file and directory permissions should I set on a new Wordpress/LAMP installation?

There is no definite answer to this. It varies depending on the server setup. The rule of thumb is to use the minimal permission to make WordPress work on a server. This means to start with 400 (or 600) and go from there, until WP works.

  • 3
    Rather than try to get the permissions opened up to the point that WP can write to wp-config.php, you can always copy the PHP code that WordPress generates and paste it into your wp-config.php file.
    – Pat J
    Apr 1, 2013 at 14:43

Related note:

On CentOS and RHEL it can happen that even with the permissions set correctly, WordPress still can't write to either .htaccess or wp-config.php. If this an issue, SELinux might be preventing those writes when set to "enforcing". In which case, change it to "permissive" or turn it off for WordPress to be able to write:

setenforce permissive


setenforce disabled    



On a VPS with Ubuntu run the following commands from within /var/www/mysite.com/public_html:

sudo chown -R myname:www-data /var/www/mysite.com/

Then run:

sudo find /var/www/mysite.com/ -type d -exec chmod 775 {} \;

That will include everything inside your mysite.com that is a directory.

Then do the same for files like so:

sudo find /var/www/mysite.com/ -type f -exec chmod 664 {} \;

Follow the above instructions and you will always have the proper file permissions on your WordPress sites on an Ubuntu server which are in accordance with the Principle of Least Privilege.

Don't just take my word for it, visit the docs: https://codex.wordpress.org/Hardening_WordPress


On the command prompt

$cat wp-config.php $chmod -Rf 777 wp-config.php

Copy the content in wp-config.php Install Wordpress Change the permission of wp-config.php to 755


Create a file wp-config.php in /var/www/blog/. Give 777 permission

  • Can you explain a little bit more as how to give permissions.
    – bravokeyl
    Aug 26, 2016 at 9:23
  • That's a very bad idea. 777 gives everyone on the server write access.
    – fuxia
    Aug 26, 2016 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.