How to fix permission denied error on any document on website
Try going up a directory, and then make sure that your user has permission to execute into wordpress. i.e. :
cd ..
vdir | grep wordpress
Related videos on Youtube
Mike Christensen
Founder and Chief Architect of KitchenPC.com, the world's most powerful recipe search engine. The technology behind KitchenPC is open-source, and available on GitHub.
Updated on September 18, 2022Comments
-
Mike Christensen almost 2 years
So, I've been trying to setup Wordpress for a while now (so much for their 5min install claim) and have just gotten stuck. No matter what, I just get:
Forbidden You don't have permission to access /wordpress/ on this server.
When I look at the
/var/www/wordpress
directory, I see:# ls -l total 276 -rw-r----- 1 www-data www-data 397 2008-05-25 20:33 index.php -rw-r----- 1 www-data www-data 7669 2011-02-15 17:48 readme.html drw-r----- 8 www-data www-data 4096 2012-03-05 20:55 wp-admin -rw-r----- 1 www-data www-data 40400 2009-10-25 10:32 wp-app.php -rw-r----- 1 www-data www-data 220 2008-10-14 06:22 wp-atom.php -rw-r----- 1 www-data www-data 274 2008-05-25 15:50 wp-blog-header.php -rw-r----- 1 www-data www-data 3928 2010-01-07 19:38 wp-comments-post.php -rw-r----- 1 www-data www-data 238 2008-10-14 06:22 wp-commentsrss2.php lrwxrwxrwx 1 www-data www-data 28 2012-03-05 20:55 wp-config.php -> /etc/wordpress/wp-config.php -rw-r----- 1 www-data www-data 2616 2009-12-08 19:59 wp-config-sample.php drw-r----- 5 www-data www-data 4096 2012-03-05 20:55 wp-content -rw-r----- 1 www-data www-data 1253 2009-08-16 04:59 wp-cron.php -rw-r----- 1 www-data www-data 220 2008-10-14 06:22 wp-feed.php drw-r----- 6 www-data www-data 4096 2012-03-05 20:55 wp-includes -rw-r----- 1 www-data www-data 1946 2009-05-05 19:43 wp-links-opml.php -rw-r----- 1 www-data www-data 2341 2009-05-20 16:32 wp-load.php -rw-r----- 1 www-data www-data 22859 2011-02-15 17:48 wp-login.php -rw-r----- 1 www-data www-data 7578 2009-09-18 20:43 wp-mail.php -rw-r----- 1 www-data www-data 487 2009-04-20 21:50 wp-pass.php -rw-r----- 1 www-data www-data 218 2008-10-14 06:22 wp-rdf.php -rw-r----- 1 www-data www-data 316 2008-05-25 15:50 wp-register.php -rw-r----- 1 www-data www-data 220 2008-10-14 06:22 wp-rss2.php -rw-r----- 1 www-data www-data 218 2008-10-14 06:22 wp-rss.php -rw-r----- 1 www-data www-data 23097 2009-12-14 00:38 wp-settings.php -rw-r----- 1 www-data www-data 3693 2009-11-26 11:29 wp-trackback.php -rw-r----- 1 www-data www-data 93445 2009-12-01 08:14 xmlrpc.php
So, www-data owns all these files. So, then I was thinking maybe apache isn't running as www-data? So I did:
# ps -A | grep apache 22511 ? 00:00:00 apache2 22513 ? 00:00:00 apache2 22514 ? 00:00:00 apache2 22515 ? 00:00:00 apache2 22516 ? 00:00:00 apache2 22517 ? 00:00:00 apache2
So, I guess apache is running as nobody? If I look at apache2.conf I see:
# These need to be set in /etc/apache2/envvars User ${APACHE_RUN_USER} Group ${APACHE_RUN_GROUP}
And in
envvars
I have:export APACHE_RUN_USER=www-data export APACHE_RUN_GROUP=www-data export APACHE_PID_FILE=/var/run/apache2.pid
So, I'm totally stuck! Any ideas?
UPDATE:
Oh, also a tail from the error.log gives me:
[Mon Mar 05 22:29:17 2012] [error] [client x.x.x.x] (13)Permission denied: access to /wordpress/index.html denied [Mon Mar 05 22:29:17 2012] [error] [client x.x.x.x] (13)Permission denied: access to /wordpress/index.cgi denied [Mon Mar 05 22:29:17 2012] [error] [client x.x.x.x] (13)Permission denied: access to /wordpress/index.pl denied [Mon Mar 05 22:29:17 2012] [error] [client x.x.x.x] (13)Permission denied: access to /wordpress/index.php denied [Mon Mar 05 22:29:17 2012] [error] [client x.x.x.x] (13)Permission denied: access to /wordpress/index.xhtml denied [Mon Mar 05 22:29:17 2012] [error] [client x.x.x.x] (13)Permission denied: access to /wordpress/index.htm denied
Update 2:
My sites-available default says:
xxx:/etc/apache2/sites-available# cat default <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/ ExpiresActive On <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all ExpiresDefault A300 ExpiresByType text/css "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" ExpiresByType application/javascript "access plus 1 month" ExpiresByType image/gif "access plus 1 month" ExpiresByType image/jpg "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/png "access plus 1 month" RewriteEngine On </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined </VirtualHost>
Sites-enabled just has 000-default pointing to that.
-
Mike Christensen over 12 yearsJust the one
default
site available, and nothing special about it.. It's configured to allow everyone and just points to/var/www
-
Mike Christensen over 12 years@LucasKauffman - I'll try 700, I did 640 cuz that was the recommended setting from some Wordpress doc..
-
Mike Christensen over 12 years
700
didn't fix it, same error.. -
Lucas Kauffman over 12 yearsWhat does your sites-available/default say ?
-
Mike Christensen over 12 years@LucasKauffman - Updated with this information..
-
Lucas Kauffman over 12 yearsmmm can't really see why it would give that error, if you create a directory in var/www/ with a simplex index.html, can you access it ?
-
Mike Christensen over 12 years@LucasKauffman - Sarah's answer fixed the issue.. Unix file permissions drive me insane..
-
-
Mike Christensen over 12 yearsAh! You rock.
/var/www/wordpress
was a symlink to/usr/share/wordpress/
- So I did achmod +x /usr/share/wordpress/
and that fixed the issue.. -
Sarah C. Corriher over 12 yearsGlad I could be of help. Also, 600 (or 640) are wiser permissions for your files. Directories need execute permissions, but php files do not, and it is always best to keep them as locked down as possible.