PHP

De MoodleDocs
Revisión del 01:45 5 jul 2014 de German Valero (discusión | contribs.) ({{Instalación de Moodle}})

Nota: Pendiente de Traducir. ¡Anímese a traducir esta página!.     ( y otras páginas pendientes)

'Nota del traductor: En esta página, la palabra extensión corresponde a la traducción del término inglés extension, aplica a las extensiones PHP, y no debe de confundirse con lo que el Español internacional usa para la traducción de plugin [sic].

PHP es el lenguaje de script en que Moodle está desarrollado. Está integrado con su servidor web. El servidor web detecta (por su extensión) las páginas PHP y las envía a PHP para que se ejecutan. PHP debe de estar instalado y configurado apropiadamente para que Moodle funcione adecuadamente (o que simplemente funcione).

Configuraciones de PHP

Revise estas configuraciones en el archivo php.ini o .htaccess (si está usando Apache). Para las configuraciones que usan SI/NO (ON/OFF) como sus valores, Usted puede sustituir 1 por ON y 0 por OFF si así lo prefiere. Si Usted cambia php.ini, no se olvide de reiniciar el servidor.

  • register_globals MUST be OFF - (Feature removed as of PHP 5.4. PHP 5.4 is a minimum requirement of Moodle 2.7)
  • safe_mode needs to be OFF - (Feature removed as of PHP 5.4. PHP 5.4 is a minimum requirement of Moodle 2.7)
  • memory_limit should be at least 64M (although some functions may not work if this low). 128M is recommended. Large systems may need an even higher setting.
  • session.save_handler needs to be set to FILES.
  • magic_quotes_gpc should be OFF - (Feature removed as of PHP 5.4. PHP 5.4 is a minimum requirement of Moodle 2.7)
  • magic_quotes_runtime needs to be OFF.
  • file_uploads needs to be ON.
  • session.auto_start needs to be OFF.
  • session.bug_compat_warn needs to be OFF - (Feature removed as of PHP 5.4. PHP 5.4 is a minimum requirement of Moodle 2.7)
  • The temp folder must be defined and writeable by your webserver user
  • Check the error display/logging section. Make sure the settings are appropriate for your server use.
  • post_max_size and upload_max_filesize restrict the maximum file size that can be uploaded.
  • Check the [mail function] and database section (for your chosen database) to make sure they match your server configuration.

Encontrar el php.ini correcto

Sometimes it is not obvious where the php.ini file is located or you may even find more than one. To be certain run 'phpinfo' - see below. The path of the php.ini file is a few lines down in the top section.

Note that if you are using command-line (CLI) PHP for running cron (or anything else) it may be configured with a different php.ini file. To check, run the following command:

php -i | grep php.ini

Extensiones y librerías PHP

The following PHP extensions are required or recommended (some, e.g. iconv, ctype and tokenizer are now included in PHP by default). Others will need to be installed or selected.

  • The iconv extension is required.
  • The mbstring extension is recommended.
  • The curl extension is required (required for networking and web services).
  • The openssl extension is recommended (required for networking and web services).
  • The tokenizer extension is recommended.
  • The xmlrpc extension is recommended (required for networking and web services).
  • The soap extension is recommended (required for web services).
  • The ctype extension is required.
  • The zip extension is required.
  • The gd extension is recommended (required for manipulating images).
  • The simplexml extension is required.
  • The spl extension is required.
  • The pcre extension is required.
  • The dom extension is required.
  • The xml extension is required.
  • The intl extension is recommended.
  • The json extension is required.
  • The appropriate extension for your chosen database is also required.
  • Other PHP extensions may be required to support optional Moodle functionality, especially external authentication and/or enrolment (e.g. LDAP extension for LDAP authentication and the sockets extension for Chat server).

Instalación de extensiones faltantes

This depends on how PHP was installed on your machine and what access you have. Here are some possibilities:

  • If this is a hosted server you are likely to have to ask the administrator or hosting company.
  • If PHP was compiled from source you will need to recompile, changing the 'configure' settings - see Compilar PHP desde código fuente.
  • If it was installed using packages (typically Linux) you can install the required package (see your Linux distribution's documentation)
  • If you are using Windows you just need to uncomment the appropriate DLL files in php.ini

After making any changes or additions, don't forget to re-start your web server.

archivos .htaccess

If you don't have access to the php.ini file or there are conflicting requirements with other PHP applications on the same server you may be able to change PHP settings in an .htaccess file. This should be placed in the 'root' of your Moodle installation (i.e. the same place as the config.php file).

The file isn't always called .htaccess and may not work at all. Contact your server administrator to be sure

Settings are made by adding lines in one of two formats:

  • php_value name value
  • php_flag name on/off

Examples:

  • php_value memory_limit 128M
  • php_flag register_globals off

Información sobre PHP

The phpinfo display contains information about the configuration of your PHP installation. This is useful for checking:

  • that your PHP installation meets Moodle's system requirements.
  • the values that are currently applied to your server's PHP install, e.g. File upload limits
  • that you have installed the required modules needed for Moodle to work, e.g. the LDAP module for LDAP authentication.

Mostrar phpinfo en Moodle

Un administrador puede ver la información sobre PHP en Configuraciones > Administración del sitio > Servidor > Información PHP .

Mostrar phpinfo fuera de Moodle

Para ver la información de phpinfo:

  • Cree un archivo llamado info.php usando su editor de texto, que solamente contenga la siguiente línea:

<?php phpinfo(); ?>

  • Guarde este archivo como info.php
  • Suba este archivo a la raíz de la carpeta accesible por web de su servidor.
  • Ahora abra este archivo en su navegador. Por ejemplo, http://<server-name>/info.php.

Vea también