一.设置软链接
由于wordpress默认附件是只能保存在根目录下,所以可以通过ftp或者软链接的方式来实现
-
阿里云:https://help.aliyun.com/document_detail/32190.html?spm=a2c4g.11174283.6.688.11f57da26VFEPb
-
通过ln命令
mkdir -p /opt/wordpress/uploads
#ln -s 源文件目录 目标文件目录
ln -s /opt/wordpress/uploads/ /var/www/html/wordpress/wp-content/
二.更改媒体库的位置
如果是直接按照上述操作来,这一步可省略,如果不想命名为upload,比如目录的名字设置为a,如wp-content/a则需要根据下面的步骤更改媒体的默认路径,只能更改源目录下路径,如wp-content/a,如果直接更换为/opt/a,可能会导致无法正常显示
2.1). 通过安装插件,在仪表盘中选择安装插件,
2.2). 找到030 Ps Display Upload_path For WP3.5并安装
2.3). 在仪表盘中选择设置,再选择媒体
2.4). 这里选择你之前在根目录下链接的地址
cd /var/www/html/wordpress/wp-content/
[root@localhost wp-content]# ll
总用量 4
-rw-r--r--. 1 root root 28 3月 22 16:26 index.php
drwxr-xr-x. 3 root root 55 3月 22 16:26 plugins
drwxr-xr-x. 5 root root 89 3月 22 16:26 themes
lrwxrwxrwx. 1 root root 23 6月 12 15:21 uploads -> /opt/wordpress/uploads/