是啊!我终于找到了解决办法!
诀窍是将所有文件和文件夹的所有权和组设置为apache用户。确保您有一个临时存储目录,并且需要../wp-content/upgrade/
目录。比你的wp-config.php
这是我唯一不知道它的兼容性。但你需要持续的FS_METHOD
设置为direct
就像“死亡医生”建议的那样。
为了让生活更简单,我创建了一个bash脚本,它非常容易使用,它将使所有内容都到位,除了wp-config.php
您必须自己将以下内容添加到此文件中。
// Some static information, so fill this in correctly.
$root=\'public_html\';
define(\'FTP_USER\',\'<username>\');
define(\'FTP_PASS\',\'<password>\');
// This is dynamically configured. You won\'t have to edit.
$addr=$_SERVER[\'SERVER_ADDR\'];
$name=$_SERVER[\'SERVER_NAME\'];
$host=$_SERVER[\'HTTP_HOST\'];
$https=$_SERVER[\'HTTPS\'];
$protocol=(!empty($https)&&$https!==\'off\'||$_SERVER[\'SERVER_PORT\']===443)?\'https://\':\'http://\';
$abspath=(strpos(getcwd(),\'/wp-admin\')!==FALSE)?substr(getcwd(),0,strrpos(getcwd(),\'/wp-admin\')):getcwd();
$relpath=substr($abspath,strrpos($abspath,$root)+strlen($root));
$tmppath=substr($abspath,0,-(strlen($relpath)+strlen($root))).\'tmp\';
define(\'WP_HOME\',$protocol.$host.$relpath);
define(\'WP_SITEURL\',$protocol.$name.$relpath);
define(\'FS_CHMOD_DIR\',(02755&~umask()));
define(\'FS_CHMOD_FILE\',(0644&~umask()));
define(\'WP_TEMP_DIR\', $tmppath);
define(\'FS_METHOD\',\'direct\');
define(\'FTP_BASE\',$abspath);
define(\'FTP_HOST\',$addr);
与bash脚本相比,它的工作原理如下:bash脚本。上海
$1 $2- $1: 选择要运行的操作帮助:显示如何使用此脚本配置:正确配置已存在的WP安装,即当前目录中安装的WP安装新建:在当前目录中安装新的WP CMS,然后正确配置
$2: 公共目录名,因此我们可以从何处检测文件是私有的。默认也是最常见的是public_html
如果服务器也使用此参数作为默认值,请将此参数保留为空现在是bash脚本本身!:D
# If requested install WP
if [ "$1" = new ]; then
wget https://wordpress.org/latest.tar.gz
tar -xvf latest.tar.gz
mv -f wordpress/* .
rm -rf wordpress/ latest.tar.gz
fi
if [[ "$1" = help || -z "$1" ]]; then
echo "Usage: install.sh \\$1 \\$2"
echo "\\$1: default=config, new=install new WP."
echo "\\$2: default=public_html, *=root folder (must be a parent)."
else
# Define root directory
if [ ! -z "$2" ]; then
root=$2
else
root=\'public_html\'
fi
# Define root path
dir=`pwd -P`
tmp=${dir%%$root*}"tmp"
# Define apache user
APACHE_USER=$(ps axho user,comm|grep -E "httpd|apache"|uniq|grep -v "root"|awk \'END {if ($1) print $1}\')
# Create missing directories
if [ ! -d "$tmp" ]; then
mkdir "$tmp"
chown -R "$APACHE_USER":"$APACHE_USER" "$tmp"
fi
if [ ! -d wp-content/upgrade ]; then
mkdir -p wp-content/upgrade
fi
# Setup group and ownership for the installation
chown -R "$APACHE_USER":"$APACHE_USER" wp-* index.php xmlrpc.php .htaccess
# Make sure the chmoding is correct
find wp-* index.php xmlrpc.php .htaccess -type f -exec chmod 644 {} \\;
find wp-* -type d -exec chmod 755 {} \\;
# Remove unwanted WP files
rm -f license.txt readme.html
fi
TIP: 要使其在系统中的任何位置都可用,只需将其放入/usr/local/bin/即可运行
$ <script name> **$1 $2**
. 确保“脚本名称”是唯一的。