wordpress install add-from-server plugin problem

 小弟最近有在企鹅云上捣鼓一个主机,有尝试安装wordpress。有遇到wordpress只支持上传2MB大小的附件这种问题;所以想办法先将大的媒体文件传到主机,然后再将媒体文件添加到wordpress的数据库中;
 现将解决方法记录如下:

install rz/sz command

Because the ftp service is not installed on the host, in order to facilitate uploading and downloading files, there is an installation of the rz/sz command. The host is centos. The installation method is as follows:

yum install lrzsz

The default source of Penguin's host has been set, so you can install it directly with yum.
Then use the terminal Xshell or Secure CRT ( putty cannot be used ), because these two terminals support Zmodem, rz and sz require the terminal to switch to Zmodem, and the commands to send and receive files are as follows:

rz \\弹出资源管理器,用户选择文件发生到云主机
sz 1.bin \\云主机发送1.bin到本地,这个会弹出资源管理器,让用户选择文件保存的本地目录

Install add-from-server

Search for add-from-server on the Internet, and put it in the wordpress/wp-content/plugins directory of wordpress, then enter the web page management terminal of wordpress, choose to load
the add-from-server plugin, the point is here, the result is unfortunately in my Prompt in centos environment:

This plugin requires WordPress 4.5 or greater, and PHP 5.4 or greater. You are currently running WordPress 4.8.1 and PHP 5.3. Please contact your website host or server administrator for more information. The plugin has been deactivated.add-from-server

The php version installed on my host is 5.3.3, and the latest version that can be installed by yum on Penguin Cloud is only 5.3.3.
I have to find a way to reinstall php, and I have to grab the source package php5.6 and install it myself. After a long time (the default host does not have a gcc compiler), after solving a bunch of compilation problems, the compilation was successful. But there are strange problems in the connection with wordpress, so give up! ! !
Then I thought of changing the 2MB limit of wordpress directly. There are various methods on the Internet, but it was unsuccessful on Penguin Cloud (I really don’t know what strange settings exist in Penguin Cloud); I
found the add-from-server code later . The amount is very small, so I thought about it: Do you want to look at the php code yourself and see if you can modify it yourself. I didn't know php at all before, I really don't know why I suddenly thought of this .
Ha, I thought of doing it, I immediately opened sublime to see the source code, and looked at php with my own C thinking, I really saw the following things, see add-from-server.php

if ( !is_admin() ) {
    return;
}

define( 'ADD_FROM_SERVER_WP_REQUIREMENT', '4.5' );
define( 'ADD_FROM_SERVER_PHP_REQUIREMENT', '5.4' );

// Old versions of WordPress or PHP
if ( version_compare( $GLOBALS['wp_version'], ADD_FROM_SERVER_WP_REQUIREMENT, '<' ) || version_compare( phpversion(), ADD_FROM_SERVER_PHP_REQUIREMENT, '<' ) ) {
    include dirname( __FILE__ ) . '/old-versions.php';
} else {
    include __DIR__ . '/class.add-from-server.php';
}

$add_from_server = new Add_From_Server( plugin_basename( __FILE__ ) );

From the above code, it should be useful to use the version_compare() method to compare whether the current wordpress and php versions meet the requirements. If it does not meet the requirements,
the code in /old-versions.php will be executed;
then look at the code in old-versions.php, as follows:

printf(
            '<div class="error"><p><strong>%s</strong>: %s</p></div>',
            __( 'Add From Server', 'add-from-server' ),
            sprintf(
                __( 'This plugin requires WordPress %1$s or greater, and PHP %2$s or greater. You are currently running WordPress %3$s and PHP %4$s. Please contact your website host or server administrator for more information. The plugin has been deactivated.', 'add-from-server' ),
                ADD_FROM_SERVER_WP_REQUIREMENT,
                ADD_FROM_SERVER_PHP_REQUIREMENT,
                $GLOBALS['wp_version'],
                phpversion()

Sure enough, it was the print when the plugin failed to install on wordpress before.
Then my modification is to

define( 'ADD_FROM_SERVER_WP_REQUIREMENT', '4.5' );
define( 'ADD_FROM_SERVER_PHP_REQUIREMENT', '5.4' );

ADD_FROM_SERVER_PHP_REQUIREMENT is changed to 5.3, after this, the plugin is installed successfully.
At first, I was worried about whether there are any new features in 5.4 that are used by add-from-server after this modification. But I am worried that it is redundant, it is completely normal to use, and you can add any media files on the host to the wordpress database.
Haha, thank you for the move! Unexpectedly, the problem was solved so easily.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325629024&siteId=291194637