Wordpress 无法上传文件

goe*_*ash 4 lamp mysql permissions apache2 wordpress

我已经使用这里的教程在本地 apache2 服务器上安装了 LAMP 堆栈和 Wordpress-

  1. https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu

  2. https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04

但是当我尝试上传媒体文件(图像/声音)时出现错误 -

The uploaded file could not be moved to wp-content/uploads/2015/01.
Run Code Online (Sandbox Code Playgroud)

可能有什么问题?我已将我的用户添加到 www-data 组并chown目录/var/www/ 以及。

saj*_*adG 15

您可以使用此脚本来修复 wordpress 权限:

#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
WS_GROUP=www-data # <-- webserver group

# reset to safe defaults
find ${WP_ROOT} -exec chown ${WP_OWNER}:${WP_GROUP} {} \;
find ${WP_ROOT} -type d -exec chmod 755 {} \;
find ${WP_ROOT} -type f -exec chmod 644 {} \;

# allow wordpress to manage wp-config.php (but prevent world access)
chgrp ${WS_GROUP} ${WP_ROOT}/wp-config.php
chmod 660 ${WP_ROOT}/wp-config.php

# allow wordpress to manage wp-content
find ${WP_ROOT}/wp-content -exec chgrp ${WS_GROUP} {} \;
find ${WP_ROOT}/wp-content -type d -exec chmod 775 {} \;
find ${WP_ROOT}/wp-content -type f -exec chmod 664 {} \;
Run Code Online (Sandbox Code Playgroud)

将它保存到一个文件并运行它并将其传递给您的 wp 安装目录:

wget https://gist.github.com/Adirael/3383404/raw/6c5446d56477426faeb709e5b807f00422acdea2/fix-wordpress-permissions.sh
chmod +x fix-wordpress-permissions.sh
sudo ./fix-wordpress-permissions.sh /var/www/html
Run Code Online (Sandbox Code Playgroud)

https://gist.github.com/Adirael/3383404