法典loosely only mentions PHP version in server requirements, 然而,PHP可以在相当广泛的范围内配置,排除/包括不同的部分。
什么是扩展/库:
WP是否需要工作MySQL
法典loosely only mentions PHP version in server requirements, 然而,PHP可以在相当广泛的范围内配置,排除/包括不同的部分。
什么是扩展/库:
WP是否需要工作MySQL
我对此进行了更多的思考,并且考虑到WP代码库(包括捆绑库)的大小,手工编译这样的列表似乎不太现实(并在每个新版本中重复它-meh)。
我找到了合适的静态代码分析工具-PHP_CompatInfo 经过一些修补,生成了以下core使用的扩展报告(版本扫描为3.3.1):
HTTP API(类WP_Http_curl
)
url_is_accessable_via_ssl()
WP_SimplePie_File
)iis7_rewrite_rule_exists()
iis7_delete_rewrite_rule()
iis7_add_rewrite_rule()
saveDomDocument()
类PHPMailer->ValidateAddress()
(可选)FTP - 72次使用
类ftp_base
ftp
(纯和插座版本)WP_Filesystem_FTPext
WP_Filesystem_ftpsockets
wp-admin\\includes\\image-edit.php
wp-admin\\includes\\image.php
wp-includes\\media.php
wp-includes\\pluggable.php
多用途(可选-在wp-includes\\compat.php
)类SimplePie
(可选)
wp_check_invalid_utf8()
(可选)wp-mail.php
(可选)JSON - 20次使用可选,在wp-includes/compat.php
类WP_oEmbed->_parse_xml()
(可选)SimplePieMultibyte String - 29个用途
在wp-includes/compat.php
类wpdb
SimplePie_Cache
WP_Feed_Cache
)类PHPMailer
类WP_oEmbed
(似乎是可选的)Sockets - 64次使用
类ftp
(sockets
实施)SPL - 3个用途
wp_doc_link_parse()
(可选)XML Parser - 89个用途SimplePie(似乎是可选的)Zlib - 30次使用
这个问题的答案可能很复杂,而且很长,据我所知,服务器和;操作系统(IIS、Apache)。。我不能说下面的列表是一个完整的列表,但它包括了我知道需要的一些列表:
系统的Mysql和Mysql–我们都知道这是什么以及为什么需要它,不是吗?
作为旁注,我还想说,这个问题可能会在serverfault上得到更多正确/更新的答案。com比此处。。。
(This is not intended to be an answer. Just some useful information. 如果您认为此信息没有什么用处,请告诉我,我会将其删除。)
我认为对于新手来说,谈论软件包会更容易,但由于软件包因系统而异,很难涵盖所有软件包。
由于我有使用Debian(基于Debian的发行版)的经验,我想分享以下具体信息:
php5-cli-php5-dev-php5-fpm-php5-cgi-php5-mysql p5 pspell前面提到的包安装了其他答案中提到的所有扩展/库/模块;all, except Mime Magic, which is no longer required by WordPress.
确保服务器与WordPress完全兼容的另一个好方法是检查托管公司预装的软件包。由于他们有多年的客户投诉不兼容的经验,他们会知道得更好。
In case of Hostgator, 他们预安装的PHP模块包括(您可能只需要大部分,但不是全部):
Media Temple提供phpinfo();
文件以检查其配置。这对于比较也很有用。
如果您想要一种简单的方法来验证您的服务器是否满足这些要求,现在有一个方便的WP-CLI ext command 这样做。
wp ext required
显示运行WordPress所需的所有PHP扩展,而wp ext recommended
显示可选的。wp ext check
是两个命令的组合。
当您需要快速检查新服务器上的系统需求和/或希望以编程方式进一步处理此列表时,这些方法非常有用。
以下是方法wp ext required
工程:
$ wp ext required
+-----------+-----------+
| extension | installed |
+-----------+-----------+
| curl | 1 |
| date | 1 |
| dom | 1 |
| filter | 1 |
| ftp | 1 |
| gd | 1 |
| hash | 1 |
| iconv | 1 |
| json | 1 |
| libxml | 1 |
| mbstring | 1 |
| mysqli | 1 |
| openssl | 1 |
| pcre | 1 |
| posix | 1 |
| SimpleXML | 1 |
| sockets | 1 |
| SPL | 1 |
| tokenizer | 1 |
| xml | 1 |
| xmlreader | 1 |
| zlib | 1 |
+-----------+-----------+
Success: All required extensions are installed
我已经开发了WordPress环境检查器。它是一个简单的类,在web SAPI或CLI上运行。这是维护版本https://github.com/szepeviktor/debian-server-tools/blob/master/webserver/php-env-check.php
<?php
/**
* Check PHP environment.
*
* Usage through a webserver
* wget -q -O - "https://example.com/php-env-check.php"; echo
* Usage on CLI
* php /path/to/php-env-check.php
*
* @package php-env-check
* @version 0.2.0
* @author Viktor Szépe <viktor@szepe.net>
*/
namespace O1;
// Local access only
if ( php_sapi_name() !== \'cli\' && $_SERVER[\'REMOTE_ADDR\'] !== $_SERVER[\'SERVER_ADDR\'] ) {
header( \'Status: 403 Forbidden\' );
header( \'HTTP/1.1 403 Forbidden\', true, 403 );
header( \'Connection: Close\' );
exit;
}
// Remove cached version of this file
if ( function_exists( \'opcache_invalidate\' ) ) {
opcache_invalidate( __FILE__ );
}
// Check environment
$check = new Check_Env();
$status = empty( $check->errors );
// Display report and exit
print json_encode( $check->errors );
exit( $status ? 0 : 1 );
/**
* Check PHP configuration.
*/
final class Check_Env {
/**
* List of errors.
*/
public $errors = array();
/**
* Run the checks.
*
* @param void
*/
public function __construct() {
// Extensions for WordPress on PHP 7.0
// http://wordpress.stackexchange.com/a/42212
// Engine version
$this->assert( \'php\', 70013, PHP_VERSION_ID );
// Core directives
$this->assert_directive( \'expose_php\', \'\' );
$this->assert_directive( \'allow_url_fopen\', \'\' );
$this->assert_directive( \'mail.add_x_header\', \'\' );
$this->assert_directive( \'realpath_cache_size\', \'64k\' );
$this->assert_directive( \'max_execution_time\', \'30\' );
$this->assert_directive( \'memory_limit\', \'128M\' );
$this->assert_directive( \'max_input_vars\', \'1000\' );
$this->assert_directive( \'post_max_size\', \'4M\' );
$this->assert_directive( \'upload_max_filesize\', \'4M\' );
// Compiled in Extensions
// php -n -m | paste -s -d " "
// Core date filter hash libxml openssl pcntl pcre Reflection session SPL standard zlib
$this->assert_extension( \'date\' );
$this->assert_directive( \'date.timezone\', \'Europe/Budapest\' );
$this->assert_extension( \'filter\' );
$this->assert_extension( \'hash\' );
$this->assert_extension( \'openssl\' );
$this->assert_extension( \'pcre\' );
$this->assert_extension( \'SPL\' );
$this->assert_extension( \'zlib\' );
// Common Extensions
// dpkg -L php7.0-common | sed -n -e \'s|^/usr/lib/php/\\S\\+/\\(\\S\\+\\)\\.so$|\\1|p\' | paste -s -d " "
// ctype iconv gettext tokenizer sockets pdo sysvsem fileinfo posix exif sysvmsg phar ftp calendar sysvshm shmop
$this->assert_extension( \'ctype\' ); // wp-includes/ID3/getid3.lib.php
$this->assert_extension( \'posix\' );
$this->assert_extension( \'exif\' ); // wp-admin/includes/image.php
$this->assert_extension( \'ftp\' );
$this->assert_extension( \'gettext\' ); // _()
$this->assert_extension( \'iconv\' );
$this->assert_extension( \'mbstring\' );
$this->assert_extension( \'sockets\' );
$this->assert_extension( \'tokenizer\' );
// php7.0-json
$this->assert_extension( \'json\' );
// php7.0-intl
$this->assert_extension( \'intl\' );
// php7.0-xml
// wddx xml simplexml xmlwriter xmlreader dom xsl
$this->assert_extension( \'xml\' );
$this->assert_extension( \'SimpleXML\' );
$this->assert_extension( \'xmlreader\' );
$this->assert_extension( \'dom\' );
// php7.0-curl
$this->assert_extension( \'curl\' );
// php7.0-gd
$this->assert_extension( \'gd\' );
// php7.0-mysql
// mysqlnd mysqli pdo_mysql
// WP_USE_EXT_MYSQL will use mysqli through mysqlnd (no PDO)
$this->assert_extension( \'mysqlnd\' );
$this->assert_extension( \'mysqli\' );
// php7.0-opcache
$this->assert_extension( \'Zend OPcache\', \'ext.opcache\' );
$this->assert_directive( \'opcache.restrict_api\', \'/home/prg123\' );
$this->assert_directive( \'opcache.memory_consumption\', \'256\' );
$this->assert_directive( \'opcache.interned_strings_buffer\', \'16\' );
$this->assert_directive( \'opcache.max_accelerated_files\', \'10000\' );
// Deprecated Extensions
$this->assert_disabled_extension( \'mcrypt\' );
$this->assert_disabled_extension( \'mysql\' );
// Disabled Extensions
// calendar fileinfo pcntl PDO pdo_mysql Phar readline
// shmop sysvmsg(System V messages) sysvsem(System V semaphore) sysvshm(System V shared memory) wddx xmlwriter xsl
$this->assert_disabled_extension( \'calendar\' );
$this->assert_disabled_extension( \'fileinfo\' );
$this->assert_disabled_extension( \'pcntl\' );
$this->assert_disabled_extension( \'PDO\' );
$this->assert_disabled_extension( \'pdo_mysql\' );
$this->assert_disabled_extension( \'Phar\' );
$this->assert_disabled_extension( \'readline\' );
$this->assert_disabled_extension( \'shmop\' );
$this->assert_disabled_extension( \'sysvmsg\' );
$this->assert_disabled_extension( \'sysvsem\' );
$this->assert_disabled_extension( \'sysvshm\' );
$this->assert_disabled_extension( \'wddx\' );
$this->assert_disabled_extension( \'xmlwriter\' );
$this->assert_disabled_extension( \'xsl\' );
// php7.0-sqlite3
// pdo_sqlite sqlite3
$this->assert_disabled_extension( \'pdo_sqlite\' );
$this->assert_disabled_extension( \'sqlite3\' );
// 3rd-party Extensions
// php7.0-redis
$this->assert_extension( \'igbinary\' );
$this->assert_extension( \'redis\' );
// Not for WordPress
// Session
$this->assert_directive( \'session.gc_maxlifetime\', \'1440\' );
}
/**
* Simple assert.
*
* @param $id string Assert ID
* @param $expected string Expected value
* @param $result string Current value
*/
private function assert( $id, $expected, $result ) {
if ( $expected !== $result ) {
$this->errors[ $id ] = $result;
}
}
/**
* Assert for a PHP extension.
*
* @param $extension_name string Extension name
* @param $id string Optional assert ID
*/
private function assert_extension( $extension_name, $id = \'\' ) {
// Automatic ID
if ( \'\' === $id ) {
$id = \'ext.\' . $extension_name;
}
$this->assert( $id, true, extension_loaded( $extension_name ) );
}
/**
* Negative assert for a PHP extension.
*
* @param $extension_name string Extension name
* @param $id string Optional assert ID
*/
private function assert_disabled_extension( $extension_name, $id = \'\' ) {
// Automatic ID
if ( \'\' === $id ) {
$id = \'!ext.\' . $extension_name;
}
$this->assert( $id, false, extension_loaded( $extension_name ) );
}
/**
* Assert for a PHP directive.
*
* @param $directive_name string Directive name
* @param $expected string Expected value
* @param $id string Optional assert ID
*/
private function assert_directive( $directive_name, $expected, $id = \'\' ) {
// Automatic ID
if ( \'\' === $id ) {
$id = $directive_name;
}
$this->assert( $id, $expected, ini_get( $directive_name ) );
}
}
基于@rarst的工作这个WordPress handbook 现在列出了推荐的PHP模块:
WordPress core使用PHP扩展。如果首选扩展丢失,WordPress将不得不做更多的工作来完成模块帮助完成的任务,或者在最坏的情况下,将删除功能。因此,建议使用下面列出的PHP扩展。
curl–执行远程请求操作
gd–如果未安装Imagick,gd图形库将用作功能有限的图像处理回退
值得一提的是,自WordPress 5.2以来,有一个内置功能可以报告缺失的模块。在“工具”>“站点运行状况”中找到它。
在Debian上安装PHP for Wordpress时的一个小“备忘”:
0. Add the dotdeb repository
将这两行添加到/etc/apt/sources.list
文件:deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all
添加GPG密钥:wget https://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg
更新“包列表”:sudo apt-get update
1. Install PHP 7:
apt-get install php7.0-common libapache2-mod-php7.0 php7.0-cli
资料来源:http://php.net/manual/en/install.unix.debian.php2. List of modules, which are included in the "php7.0-common" package:
/usr/lib/php/20151012/calendar.so
/usr/lib/php/20151012/ctype.so
/usr/lib/php/20151012/exif.so
/usr/lib/php/20151012/fileinfo.so
/usr/lib/php/20151012/ftp.so
/usr/lib/php/20151012/gettext.so
/usr/lib/php/20151012/iconv.so
/usr/lib/php/20151012/pdo.so
/usr/lib/php/20151012/phar.so
/usr/lib/php/20151012/posix.so
/usr/lib/php/20151012/shmop.so
/usr/lib/php/20151012/sockets.so
/usr/lib/php/20151012/sysvmsg.so
/usr/lib/php/20151012/sysvsem.so
/usr/lib/php/20151012/sysvshm.so
/usr/lib/php/20151012/tokenizer.so
资料来源:https://packages.debian.org/sid/amd64/php7.0-common/filelist3. To install the additional modules which are required/recommended by wordpress:
apt-get install php7.0-curl php7.0-gd php7.0-mbstring php7.0-mcrypt php7.0-pspell php7.0-zip
资料来源:https://wordpress.stackexchange.com/a/42141/1078784. I couldn\'t find the following on debian:
Openssl
Path Info Check
Zlib
5. "apt-cache search php7" returns:
php7.0 - server-side, HTML-embedded scripting language (metapackage)
php7.0-apcu - APC User Cache for PHP
php7.0-apcu-bc - APCu Backwards Compatibility Module
php7.0-bcmath - Bcmath module for PHP
php7.0-bz2 - bzip2 module for PHP
php7.0-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.0-cli - command-line interpreter for the PHP scripting language
php7.0-common - documentation, examples and common module for PHP
php7.0-curl - CURL module for PHP
php7.0-dba - DBA module for PHP
php7.0-dbg - Debug symbols for PHP7.0
php7.0-dev - Files for PHP7.0 module development
php7.0-enchant - Enchant module for PHP
php7.0-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php7.0-gd - GD module for PHP
php7.0-geoip - GeoIP module for PHP
php7.0-gmp - GMP module for PHP
php7.0-igbinary - igbinary serializer for PHP
php7.0-imagick - Provides a wrapper to the ImageMagick library
php7.0-imap - IMAP module for PHP
php7.0-interbase - Interbase module for PHP
php7.0-intl - Internationalisation module for PHP
php7.0-json - JSON module for PHP
php7.0-ldap - LDAP module for PHP
php7.0-mbstring - MBSTRING module for PHP
php7.0-mcrypt - libmcrypt module for PHP
php7.0-memcached - memcached extension module for PHP, uses libmemcached
php7.0-mongodb - MongoDB driver for PHP
php7.0-msgpack - MessagePack serializer for PHP
php7.0-mysql - MySQL module for PHP
php7.0-odbc - ODBC module for PHP
php7.0-opcache - Zend OpCache module for PHP
php7.0-pgsql - PostgreSQL module for PHP
php7.0-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)
php7.0-pspell - pspell module for PHP
php7.0-readline - readline module for PHP
php7.0-recode - recode module for PHP
php7.0-redis - PHP extension for interfacing with Redis
php7.0-snmp - SNMP module for PHP
php7.0-soap - SOAP module for PHP
php7.0-sqlite3 - SQLite3 module for PHP
php7.0-ssh2 - Bindings for the libssh2 library
php7.0-sybase - Sybase module for PHP
php7.0-tidy - tidy module for PHP
php7.0-xdebug - Xdebug Module for PHP
php7.0-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.0-xmlrpc - XMLRPC-EPI module for PHP
php7.0-xsl - XSL module for PHP (dummy)
php7.0-zip - Zip module for PHP
参考号:https://packages.debian.org/source/sid/php7.0您需要mysqli、pdo和gd扩展。有时还有xml rpc。
我已经用mysqlnd本机扩展运行WP有一段时间了,它非常整洁。有内置的反射功能,所以如果您想查看该特定请求中db的情况,可以这样做。
zip不需要扩展,大多数程序调用系统zip可执行文件。
正式地WordPress.org 表示自WP Core 5.3+起,在使用推荐的PHP版本(当前为PHP 7.2)时,只需要以下PHP扩展:
curl -- Performs remote request operations.
dom -- Used to validate Text Widget content and to automatically configuring IIS7+.
exif -- Works with metadata stored in images.
fileinfo -- Used to detect mimetype of file uploads.
hash -- Used for hashing, including passwords and update packages.
json -- Used for communications with other servers.
mbstring -- Used to properly handle UTF8 text.
mysqli -- Connects to MySQL for database interactions.
libsodium -- Validates Signatures and provides securely random bytes.
openssl -- Permits SSL-based connections to other hosts.
pcre -- Increases performance of pattern matching in code searches.
imagick -- Provides better image quality for media uploads. See WP_Image_Editor is incoming! for details. Smarter image resizing (for smaller images) and PDF thumbnail support, when Ghost Script is also available.
xml -- Used for XML parsing, such as from a third-party site.
zip -- Used for decompressing Plugins, Themes, and WordPress update packages.
。。。但他们也推荐以下可选扩展:filter -- Used for securely filtering user input.
gd -- If Imagick isn’t installed, the GD Graphics Library is used as a functionally
limited fallback for image manipulation.
iconv -- Used to convert between character sets.
mcrypt -- Generates random bytes when libsodium and /dev/urandom aren’t available.
simplexml -- Used for XML parsing.
xmlreader -- Used for XML parsing.
zlib -- Gzip compression and decompression.
但是,请记住,其中一些必需(或可选)扩展已经绑定到其他PHP包中。例如dom
通常包含在xml
扩大其他人喜欢fileinfo
可能已经作为所谓php-common
如果您正在使用Ubuntu等,请打包。此外,还有一些其他扩展,如bcmath
WordPress没有正式要求或推荐,但许多流行插件仍在使用,如Yoast SEO。
你可以按照我们的list of WordPress PHP extensions 如果有兴趣的话就去小比兹。
Jeditable正在将数据保存到文件中,如下所示:$(\'.edit_area\').editable(\'http://www.example.com/save.php\', { type : \'textarea\', cancel : \'Cancel\', submit : \'OK\', indicator : \'<img src=\"img/indicato