wordpress:cli container is not able to manipulate files on a volume shared with wordpress container.
Here's the docker-compose.yml file I use to bootstrap WordPress:
version: "3"
services:
wordpress:
image: wordpress
ports: ["80:80"]
volumes: ["wp_test:/var/www/html"]
environment:
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: secret
mysql:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: secret
cli:
image: wordpress:cli
volumes: ["wp_test:/var/www/html"]
command: sh -c "sleep 20 && wp core install --path=/var/www/html --url=localhost --title=test --admin_user=test --admin_password=test --admin_email=test#example.com"
volumes:
wp_test:
I start it with docker-compose up and when wp-cli sets up the installation, there is a warning:
cli_1 | Warning: Unable to create directory wp-content/uploads/2018/02. Is its parent directory writable by the server?
The installation works so far, but I'd like to fix this warning, because for other wp-cli tasks manipulating files is critical.
From inside wordpress container, privileges look like this:
drwxr-xr-x 5 www-data www-data 4096 Feb 2 11:21 .
drwxr-xr-x 4 root root 4096 Jan 4 01:30 ..
-rw-r--r-- 1 www-data www-data 234 Feb 2 11:21 .htaccess
-rw-r--r-- 1 www-data www-data 418 Sep 25 2013 index.php
-rw-r--r-- 1 www-data www-data 19935 Jan 6 19:32 license.txt
-rw-r--r-- 1 www-data www-data 7413 Dec 12 2016 readme.html
-rw-r--r-- 1 www-data www-data 5434 Sep 23 12:21 wp-activate.php
drwxr-xr-x 9 www-data www-data 4096 Jan 16 21:39 wp-admin
-rw-r--r-- 1 www-data www-data 364 Dec 19 2015 wp-blog-header.php
-rw-r--r-- 1 www-data www-data 1627 Aug 29 2016 wp-comments-post.php
-rw-r--r-- 1 www-data www-data 2764 Feb 2 11:21 wp-config-sample.php
-rw-r--r-- 1 www-data www-data 3144 Feb 2 11:21 wp-config.php
drwxr-xr-x 4 www-data www-data 4096 Feb 2 11:22 wp-content
-rw-r--r-- 1 www-data www-data 3669 Aug 20 04:37 wp-cron.php
drwxr-xr-x 18 www-data www-data 12288 Jan 16 21:39 wp-includes
-rw-r--r-- 1 www-data www-data 2422 Nov 21 2016 wp-links-opml.php
-rw-r--r-- 1 www-data www-data 3306 Aug 22 11:52 wp-load.php
-rw-r--r-- 1 www-data www-data 36583 Oct 13 02:10 wp-login.php
-rw-r--r-- 1 www-data www-data 8048 Jan 11 2017 wp-mail.php
-rw-r--r-- 1 www-data www-data 16246 Oct 4 00:20 wp-settings.php
-rw-r--r-- 1 www-data www-data 30071 Oct 18 17:36 wp-signup.php
-rw-r--r-- 1 www-data www-data 4620 Oct 23 22:12 wp-trackback.php
-rw-r--r-- 1 www-data www-data 3065 Aug 31 2016 xmlrpc.php
but from within cli container the same volume looks like this:
drwxr-xr-x 5 www-data www-data 4096 Feb 2 11:21 .
drwxr-xr-x 3 root root 4096 Jan 10 07:36 ..
-rw-r--r-- 1 xfs xfs 234 Feb 2 11:21 .htaccess
-rw-r--r-- 1 xfs xfs 418 Sep 25 2013 index.php
-rw-r--r-- 1 xfs xfs 19935 Jan 6 19:32 license.txt
-rw-r--r-- 1 xfs xfs 7413 Dec 12 2016 readme.html
-rw-r--r-- 1 xfs xfs 5434 Sep 23 12:21 wp-activate.php
drwxr-xr-x 9 xfs xfs 4096 Jan 16 21:39 wp-admin
-rw-r--r-- 1 xfs xfs 364 Dec 19 2015 wp-blog-header.php
-rw-r--r-- 1 xfs xfs 1627 Aug 29 2016 wp-comments-post.php
-rw-r--r-- 1 xfs xfs 2764 Feb 2 11:21 wp-config-sample.php
-rw-r--r-- 1 xfs xfs 3144 Feb 2 11:21 wp-config.php
drwxr-xr-x 4 xfs xfs 4096 Feb 2 11:22 wp-content
-rw-r--r-- 1 xfs xfs 3669 Aug 20 04:37 wp-cron.php
drwxr-xr-x 18 xfs xfs 12288 Jan 16 21:39 wp-includes
-rw-r--r-- 1 xfs xfs 2422 Nov 21 2016 wp-links-opml.php
-rw-r--r-- 1 xfs xfs 3306 Aug 22 11:52 wp-load.php
-rw-r--r-- 1 xfs xfs 36583 Oct 13 02:10 wp-login.php
-rw-r--r-- 1 xfs xfs 8048 Jan 11 2017 wp-mail.php
-rw-r--r-- 1 xfs xfs 16246 Oct 4 00:20 wp-settings.php
-rw-r--r-- 1 xfs xfs 30071 Oct 18 17:36 wp-signup.php
-rw-r--r-- 1 xfs xfs 4620 Oct 23 22:12 wp-trackback.php
-rw-r--r-- 1 xfs xfs 3065 Aug 31 2016 xmlrpc.php
While user in cli container is www-data (just like it is in wordpress container), it cannot create the desired folder:
$ mkdir -p wp-content/uploads/2018/02
mkdir: can't create directory 'wp-content/uploads/': Permission denied
I'm running docker compose 1.18.0 and and docker engine 17.12.0-ce on a mac.
I also created a github issue.
I assume your question is "How do I fix WP-CLI file permission problems using Docker volumes?"
You need to make sure to run wp-cli as the same UID in both containers.
From the command line:
docker run -it --rm \
--volumes-from $container \
--network container:$container \
--user 33:33 \
wordpress:cli core install --path=/var/www/html --url=localhost --title=test --admin_user=test --admin_password=test --admin_email=test#example.com
--user 33:33 is a workaround to run wp-cli with the same UID/GID as www-data in the WordPress container. Problems arise because the containers have different UID/GID for www-data. See https://github.com/docker-library/wordpress/issues/256
You should be able to add user: "33:33" to your docker-compose file as well. See https://github.com/docker/compose/issues/1532
Related
My Nginx server threw the warning:
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
I created nginx-group and nginx-user
groupadd --system --gid 7447 nginx-group
adduser --system --gid 7447 --uid 7447 nginx-user
The Nginx process owned by my user "nginx-user"
bash-4.2$ ps -ef | grep [n]ginx
nginx-u+ 1 0 0 08:05 ? 00:00:00 nginx: master process nginx -g daemon off;
nginx-u+ 7 1 0 08:05 ? 00:00:00 nginx: worker process
The /etc/nginx folder and content owned by the root user
bash-4.2$ ls -la /etc/nginx
total 20
drwxr-xr-x 1 root root 20 Aug 1 07:33 .
drwxr-xr-x 1 root root 41 Aug 1 08:05 ..
drwxr-xr-x 1 root root 54 Aug 1 07:33 conf.d
-rw-r--r-- 1 root root 1007 May 24 15:35 fastcgi_params
-rw-r--r-- 1 root root 3957 Aug 1 07:05 mime.types
lrwxrwxrwx 1 root root 29 Aug 1 07:33 modules -> ../../usr/lib64/nginx/modules
-rw-r--r-- 1 root root 2200 Aug 1 07:05 nginx.conf
-rw-r--r-- 1 root root 636 May 24 15:35 scgi_params
drwxr-xr-x 1 root root 22 Aug 1 07:33 sites-available
drwxr-xr-x 1 root root 22 Aug 1 07:33 sites-enabled
-rw-r--r-- 1 root root 664 May 24 15:35 uwsgi_params
Anyone can help to fix this warning ?
I'm currently using Symfony 3.4.8 with up to date dependencies.
In production, symfony creates "prod?" directory :
drwxrwxrwx 4 www-data www-data 434 Apr 20 10:26 .
drwxr-xr-x 4 www-data www-data 45 Apr 20 10:21 ..
-rw-rw-rw- 1 www-data www-data 165 Apr 20 10:26 annotations.map
drwxrwxrwx 2 www-data www-data 15K Apr 20 10:26 ContainerDcnvgsr
-rw-rw-rw- 1 www-data www-data 106K Apr 20 10:26 srcProd?DebugProjectContainerCompiler.log
-rw-rw-rw- 1 www-data www-data 628 Apr 20 10:26 srcProd?DebugProjectContainerDeprecations.log
-rw-rw-rw- 1 www-data www-data 784 Apr 20 10:26 srcProd?DebugProjectContainer.php
-rw-rw-rw- 1 www-data www-data 21K Apr 20 10:26 srcProd?DebugProjectContainer.php.meta
-rw-rw-rw- 1 www-data www-data 347K Apr 20 10:21 srcProd?DebugProjectContainer.xml
-rw-rw-rw- 1 www-data www-data 21K Apr 20 10:21 srcProd?DebugProjectContainer.xml.meta
drwxrwxrwx 2 www-data www-data 0 Apr 20 10:21 vich_uploader
var/cache directory :
drwxr-xr-x 4 www-data www-data 45 Apr 20 10:21 .
drwxr-xr-x 4 www-data www-data 44 Apr 19 11:38 ..
drwxr-xr-x 9 www-data www-data 556 Apr 19 11:42 prod
drwxrwxrwx 4 www-data www-data 434 Apr 20 10:26 prod?
public directory :
drwxr-xr-x 3 www-data www-data 104 Apr 19 11:39 build
drwxr-xr-x 2 www-data www-data 27 Apr 19 11:38 bundles
drwxrwxrwx 2 www-data www-data 98 Apr 19 09:27 imports
-rw-rw-rw- 1 www-data www-data 1242 Apr 19 09:27 index.php
Most of users have the following error :
(1/1) FatalThrowableError
Parse error: syntax error, unexpected
'DebugProjectContainer' (T_STRING), expecting ',' or ')'
The app works for few users with the correct "prod" cache directory and no error.
How can I fix this ?
There was a special character (^M) at the end of each line in the .env file due to a bad copy/paste.
¯\_(ツ)_/¯
I'm trying to install the wordpress plugging but just can't bypass this FTP credential page.
I have tried:
1, add FS_METHOD: 'direct' to wp-config.php
2, change permission on the file folder, see blow,
Still just can't have it working, please help
:/var/www/html/wordpressblog# ls -la
total 196
drwxr-xr-x 5 nobody nogroup 4096 Jan 15 08:43 .
drwxr-xr-x 3 nobody nogroup 4096 Jan 15 07:36 ..
-rw-r--r-- 1 nobody nogroup 418 Sep 25 2013 index.php
-rw-r--r-- 1 nobody nogroup 19935 Jan 3 2017 license.txt
-rw-r--r-- 1 nobody nogroup 7413 Dec 12 2016 readme.html
-rw-r--r-- 1 nobody nogroup 5434 Sep 23 20:21 wp-activate.php
drwxr-xr-x 9 nobody nogroup 4096 Nov 30 03:06 wp-admin
-rw-r--r-- 1 nobody nogroup 364 Dec 19 2015 wp-blog-header.php
-rw-r--r-- 1 nobody nogroup 1627 Aug 29 2016 wp-comments-post.php
-rw-r--r-- 1 nobody nogroup 2901 Jan 15 08:43 wp-config.php
drwxrwxrwx 4 nobody nogroup 4096 Nov 30 03:06 wp-content
-rw-r--r-- 1 nobody nogroup 3669 Aug 20 12:37 wp-cron.php
drwxr-xr-x 18 nobody nogroup 12288 Nov 30 03:06 wp-includes
-rw-r--r-- 1 nobody nogroup 2422 Nov 21 2016 wp-links-opml.php
-rw-r--r-- 1 nobody nogroup 3306 Aug 22 19:52 wp-load.php
-rw-r--r-- 1 nobody nogroup 36583 Oct 13 10:10 wp-login.php
-rw-r--r-- 1 nobody nogroup 8048 Jan 11 2017 wp-mail.php
-rw-r--r-- 1 nobody nogroup 16246 Oct 4 08:20 wp-settings.php
-rw-r--r-- 1 nobody nogroup 30071 Oct 19 01:36 wp-signup.php
-rw-r--r-- 1 nobody nogroup 4620 Oct 24 06:12 wp-trackback.php
-rw-r--r-- 1 nobody nogroup 3065 Sep 1 2016 xmlrpc.php
/var/www# ls -la
drwxr-xr-x 3 root root 4096 Jan 10 10:28 .
drwxr-xr-x 12 root root 4096 Jan 10 10:28 ..
drwxr-xr-x 3 nobody nogroup 4096 Jan 15 07:36 html
The wp-content directory needs to be owned by the same user and group than the webserver. You might need to change these settings, e.g. in the httpd.conf if you are using apache
I encountered this before when I setup my own web server using nginx. The whole /var/www/html folder and all descendants need to be owned by the same user running nginx worker to enable install plugin without ftp inside wordpress dashboard for my case. Hope it helps!
I have two user groups, webuser and www-data. When applied on the root directory as such chown -R webuser:webuser . I'm able to access the wordpress backend, same goes for www-data:www-data. But when mixing them both as webuser:www-data I'm unable to render the backend, the error presented is.
Forbidden
You don't have permission to access /wp-admin/update-core.php on this server.
Server unable to read htaccess file, denying access to be safe
I then tried assigning the .htaccess file as both webuser:webuser and www-data:www-data but the same error is still shown.
The current user groups have the following
public$ groups
webuser www-data
public$ groups webuser
webuser : webuser www-data
public$ groups www-data
www-data : www-data
The root files are all marked as 664.
What is missing in order to allow wordpress to manually update from the backend, I'm with allowing ftp credentials for login.
Edit:
File/folder permissions
drwxr-xr-x 5 webuser webuser 4096 Feb 15 21:45 .
drwxr-xr-x 7 webuser webuser 4096 Aug 18 00:50 ..
-rw-r--r-- 1 webuser webuser 6148 Aug 18 01:44 .DS_Store
-rw-r--r-- 1 webuser webuser 40444 Nov 5 20:49 .htaccess
-rw-rw-r-- 1 webuser webuser 418 Sep 16 21:56 index.php
-rw-r--r-- 1 webuser webuser 19930 Jan 19 03:09 license.txt
-rw-rw-r-- 1 webuser webuser 5035 Jan 19 03:09 wp-activate.php
drwxrw-r-x 9 webuser webuser 4096 Aug 18 01:45 wp-admin
-rw-rw-r-- 1 webuser webuser 271 Sep 16 21:56 wp-blog-header.php
-rw-rw-r-- 1 webuser webuser 1369 Jan 19 03:09 wp-comments-post.php
-rw-rw-r-- 1 webuser webuser 2853 Jan 19 03:09 wp-config-sample.php
-rw-rw-r-- 1 webuser webuser 3041 Aug 18 02:15 wp-config.php
drwxrwxr-x 8 www-data www-data 4096 Feb 14 23:54 wp-content
-rw-rw-r-- 1 webuser webuser 3286 Sep 16 21:56 wp-cron.php
drwxr-xr-x 16 webuser webuser 4096 Jan 19 03:09 wp-includes
-rw-rw-r-- 1 webuser webuser 2380 Sep 16 21:56 wp-links-opml.php
-rw-rw-r-- 1 webuser webuser 3316 Jan 19 03:09 wp-load.php
-rw-rw-r-- 1 webuser webuser 33770 Jan 19 03:09 wp-login.php
-rw-rw-r-- 1 webuser webuser 7887 Jan 19 03:09 wp-mail.php
-rw-rw-r-- 1 webuser webuser 13021 Jan 19 03:09 wp-settings.php
-rw-rw-r-- 1 webuser webuser 28594 Jan 19 03:09 wp-signup.php
-rw-rw-r-- 1 webuser webuser 4035 Sep 16 21:56 wp-trackback.php
-rw-rw-r-- 1 webuser webuser 3061 Jan 19 03:09 xmlrpc.php
I have a wordpress blog on a server, the admin portal is also on the same server.
The auto update of plugins from the admin portal is not working.
I get an error saying that I am not authorize to login.
Error message - Error: There was an error connecting to the server, Please verify the settings are correct.
I know the login details are correct.
Could the problem be that the server is trying to connect to itself ?
I have looked at the other articles about this problem, I havent got SELinex installed and the permissions seem to be correct.
Directories
-rw-r--r-- 1 root root 200 May 23 2010 .htaccess
-rw-r--r-- 1 www-data www-data 1406 May 16 2010 favicon.ico
-rw-r--r-- 1 www-data www-data 397 May 25 2008 index.php
-rw-r--r-- 1 www-data www-data 15410 Dec 6 2008 license.txt
drwxr-xr-x 6 www-data www-data 4096 Jul 28 2010 mint
-rw-r--r-- 1 www-data www-data 9122 Jul 22 2010 readme.html
-rw-r--r-- 1 www-data www-data 4391 Apr 19 2010 wp-activate.php
drwxr-xr-x 7 www-data www-data 4096 Sep 3 12:33 wp-admin
-rw-r--r-- 1 www-data www-data 40284 Jul 25 2010 wp-app.php
-rw-r--r-- 1 www-data www-data 220 Oct 14 2008 wp-atom.php
-rw-r--r-- 1 www-data www-data 274 May 25 2008 wp-blog-header.php
-rw-r--r-- 1 www-data www-data 3926 May 6 2010 wp-comments-post.php
-rw-r--r-- 1 www-data www-data 238 Oct 14 2008 wp-commentsrss2.php
-rw-r--r-- 1 www-data www-data 3173 May 25 2010 wp-config-sample.php
-rw-r--r-- 1 www-data www-data 3208 Sep 5 14:49 wp-config.php
drwxrw-rw- 19 www-data www-data 4096 Feb 8 21:59 wp-content
-rw-r--r-- 1 www-data www-data 1255 Mar 17 2010 wp-cron.php
-rw-r--r-- 1 www-data www-data 240 Apr 19 2010 wp-feed.php
drwxr-xr-x 7 www-data www-data 4096 Sep 3 12:41 wp-includes
-rw-r--r-- 1 www-data www-data 2002 Mar 18 2010 wp-links-opml.php
-rw-r--r-- 1 www-data www-data 2441 Feb 28 2010 wp-load.php
-rw-r--r-- 1 www-data www-data 26059 Jun 1 2010 wp-login.php
-rw-r--r-- 1 www-data www-data 7774 May 26 2010 wp-mail.php
-rw-r--r-- 1 www-data www-data 487 Apr 20 2009 wp-pass.php
-rw-r--r-- 1 www-data www-data 218 Oct 14 2008 wp-rdf.php
-rw-r--r-- 1 www-data www-data 316 May 25 2008 wp-register.php
-rw-r--r-- 1 www-data www-data 218 Oct 14 2008 wp-rss.php
-rw-r--r-- 1 www-data www-data 220 Oct 14 2008 wp-rss2.php
-rw-r--r-- 1 www-data www-data 9177 May 2 2010 wp-settings.php
-rw-r--r-- 1 www-data www-data 18695 Jul 21 2010 wp-signup.php
-rw-r--r-- 1 www-data www-data 3702 Feb 24 2010 wp-trackback.php
-rw-r--r-- 1 www-data www-data 94184 Jul 14 2010 xmlrpc.php
Thanks, Alex
Try to give www-data permission in wordpress directory:
cd /yourwordpressdirectory/
sudo chown -R www-data:www-data *