Learn WordPress while having breakfast: Avoid installing and uninstalling plugins and themes

In this new video of the series created with SiteGround I explain a wonderful trick that I have been applying for years to client websites to prevent you from installing or uninstalling plugins and themes.

Inside video !

The code spoken of in the video is none other than this:

 define ('DISALLOW_FILE_MODS', true); 

Enjoy it!

The entry Learn WordPress while breakfast: Avoid installation and uninstallation of plugins and themes first published Fernando Tellado in WordPress Help . Do not copy content, do not say anything good about you to your readers.

Internal Server Error / Internal server error

One of the errors that gives less information at the time of showing itself, and consequently more scare, is the terrifying one Server internal error or, if it leaves in English, Internal Server Error .

One would think that, being the server, the only solution is, then, to call server, the provider of your hosting, and is not badly thought.

In any case is a bloody mistake, because you know that something is not right, but it gives you no clue what is broken

But in reality does not have to be an error of your hosting, they can be many things so we are going to see the possible culprits of an internal error of the server and how to fix it in our web WordPress.

What causes an internal server error?

There are several po sibles culprits namely:

  • Plugins
  • Topic
  • WordPress installation
  • File .htaccess
  • PHP memory
  • Your hosting

To know what is the culprit my advice is to follow this sequence of actions:

Regenerate the file .htaccess

To eliminate the biggest suspect of an internal error of the server, Not the only one, I always start reviewing the file .htaccess .

The problem with this file is that there are many plugins that add lines so that sometimes guess what could have caused the problem is complicated especially if you have no knowledge of servers.

So the easiest, and sure, is to do the following:

  1. Access via FTP or the cPanel of your hosting and rename the current file .htaccess to something else, for example antigua.htaccess
  2. If you go to your site and the internal error of the server has been fixed, access your WordPress desktop, that is, at tudominio.es/wp-admin/
  3. Ve a Settings> Permanent links and Saves changes without modifying any settings.

What you have done is force WordPress to generate a new file .htaccess ] clean only with the WordPress rules, and by the way you know it was something in the old.htaccess what caused the error.

Now you have to check what was in that file , that's why you have the copy, which caused the error.

Disable the plugins

The next possible culprit is the plugins simply because can load functions that insert lines in the file .htaccess or break WordPress and all your installation if there is a problem of pr o

As we will not have access to the administration, access your installation of WordPress by FTP or cPanel and rename the folder plugins that is, change the folder that is in the path / wp-content / plugins / to something else, for example / wp-content / plugins_rotos /

What you do with this is disable all plugins automatically ]well you do not, WordPress, not finding the standard path where the plugins are installed.

Visit your site, and if the server's internal error has been fixed, rename the plugins folder to its original name. [19659006] Now you can access the WordPress desktop again, but with all the plugins inactive.

The following you already know, or imagine, right? You have to activate plugins one by one and checking which is causing the internal server error or Internal Server Error .

Once located, to deactivate it, rename your folder or delete it directly by FTP or the panel of your hosting, get in touch with the developer to let them know and offer you a solution, and look for an alternative plugin that offers the same functionality but without errors.

Changes theme … temporarily

If the plugins are not, also the active theme could cause an internal error of the server .

And it is that the themes not only make your web look beautiful and functional, also include (increasingly) internal functions, practically plugins which like your plugins can cause an internal server error.

Here the solution is similar to the previous one, and we will take advantage of ] a trick not very known WordPress, at least not as well known as I would like .

Again, access your installation via FTP or cPanel and check if, in addition to the currently active topic, you have installed a recent default theme of WordPress; I mean the Twenty Something .

If you do not have any of these installed download it from the official WordPress themes directory and upload it to your WordPress installation themes folder ( / wp-content / themes / ).

Once this is done rename the current theme folder to whatever you want . For example, from / wp-content / themes / my-theme / to / wp-content / themes / my-theme-broken / .

In a few seconds WordPress will detect that the current theme is not available in the path stored in the database and it will change to the first default theme that it finds installed, pure WordPress magic .

Now visit your site to check if this has managed to fix the server's internal error.

If so, talk to the developer, get a clean copy of your favorite theme or look for another that offers the same but without errors.

Upload the memory of PHP

] Another possible culprit can be that you have little memory for PHP a directive that is usually marked by default by hosting companies, but that we can manipulate to a certain extent.

If none of the above has worked this could be the problem, so we will try to force r memory available for PHP the programming language used by WordPress, its plugins and issues massively.

This is so because they can match processes on your website at a given time that exceed that available memory, and force a internal error of the server.

It can be, for example, an automated task of a plugin that coincides with the publication of an entry or go to know.

Whatever it is, we will increase the limit of the memory of PHP to check if it was that. To achieve this we have to try to bypass the limits imposed by the server, which we can achieve in several ways.

Increase the PHP memory limit from .htaccess

Add to the file .htaccess the following line :

Save the changes and check to see if the server's internal error was fixed.

Increase the PHP memory limit from wp-config.php

If the above does not work for you, delete that line and add this one to your file wp-config.php :

Again, save the changes and check your website to see if you no longer have the Internal Server Error of the noses.

Increase the memory limit to PHP from php.ini

If you have full access to all the routes of your hosting, locate the PHP parameter configuration file, called php.ini and change the PHP memory limit line to these values:

If not you have access to the file path php.ini original you can create yourself one in the folder wp-admin and add the following:

And if all else fails … call your hosting

If none of the above solves the problem talk to your hosting provider, with your hosting and inform them. They have access to all your server, to the error logs and can more easily determine what caused the problem .

In addition, you can increase, even temporarily, the available memory, so you can review the steps that we have seen previously.

I hope this guide has helped you solve some Internal Server Error or internal server error . If that's the case, share how you managed it with everyone, so you'll help others too.

Loading …

That may also help you:

How to change the location of the uploads folder in WordPress

Until not long ago we could easily change the location of the folder to which we uploaded the images and other files but from WordPress 3.5 that wonderful field that we had in " Settings -> Media " disappeared.

Fortunately it is very easy to make this change, and we have 2 methods to get it.

Choose file upload folder with a plugin

Easier impossible Do you want to recover the setting that allowed to change the location of the folder where the files are uploaded in WordPress?

Well we have two plugins, that I know at least, that recover it, as well of simple.

  • WP Original Media Path : Add an "expert" setting on the new page of Settings> WP Original Media Path from which to change the folder for your uploaded files.
  • ] Upload Url and Path En Abler : Cleaner than the previous one, simply recover the setting to be able to change the file upload path in Settings> Media of the administration of your WordPress.

Basically we changed this … [19659003]  Settings upload wordpress files

To recover with Upload URL and Path Enable the settings that had been before WordPress 3.5, these …

OR to a new setting, and something more limited, with WP Original Media Path …

Choose file upload folder with code

If you opt for this possibility it is also easy , just add a small code to the WordPress configuration file ( wp-config.php ) to define the folder to which the images will be uploaded, pdf and others by default .

The best of all is that works just like the folder by default, automatically creating folders by year and month if you wish .

 upload wordpress files

The line to add, yes, before line require_once (ABSPATH.'wp-settings.php '); it would be like this:

Logically you have to change the example path to which your

That's right, personally I recommend, for greater certainty, that completely change the route of " wp-content " as I explained a long time ago.

] Loading …

That may also help you:

How to modify the wp-config.php file without leaving WordPress

The WordPress configuration file, the famous wp config . php has multiple possible settings that we can add or modify but and what if we dare to do it without leaving our WordPress desktop?

Although I personally do not recommend ever modifying system files from the desktop, and this one is, there are times when you may need to modify some variable in the file wp config . php and I'll catch you without your own computer from which to access the cPanel of your hosting or by FTP .

It is on these occasions that plugins like WP Config File Editor can come to the rescue . [19659017]

Once installed and active you have a very complete interface, tant or through web form as in code editor, from which to do a lot of modifications :

  • Backup and restoration of wp-config.php.
  • Wizard and configurations for multisite. [19659020] Increase memory limits
  • Activate cache.
  • Configure parameters in entries, such as revisions, autosave, and more.
  • Configure language.
  • Configure WordPress security.
  • ] Configure the WordPress proxy.
  • Configure the access parameters to the WordPress database.
  • Test connection to the WordPress database access parameters.
  • Configure the repair of the WordPress database.
  • Configure automatic WordPress updates.
  • Configure cron.
  • Configure debug.
  • Configure security keys.
  • Change security keys to a click . [19659020] Filtering and validation of the entered fields to avoid breaking the file wp-config.php.
  • Change the values ​​of routes and URLs of the system.
  • List of constants associated with each field that you can modify.
  • Help in each field.
  • Save your configurations in different profiles.
  • Renew cookie name constants in one click.
  • Check system requirements.
  • Enable / disable write permissions for files. wp-config.php and .htaccess.
  • A lot more parameters.

The interface, immense, it's like this …

Is the plugin cool? Of course . It is complete? So much that it scares. Should I use it? Well only on very special occasions and for reasons of force majeure .

Also, keep in mind that in order to do something your file wp config . php must have write permissions, something I never recommend.

In any case it is good that you know him, because in more than one occasion you can get out of trouble . And it is also recommended for users who, wanting to make modifications to their file wp config . php do not feel comfortable with code editors and prefer to change parameters from a form.

In all cases use it under your responsibility .

Loading …

You may also find it helpful:

Everything you wanted to know and much more

The file wp config . php en one of the most important of any WordPress installation in fact it is the WordPress configuration file with sensitive and important information that will make your site work correctly or even not work at all .

That's why it's vitally important to know it in depth, and that's what I want us to learn today, do you dare?

In any WordPress installation there is a default configuration file, named wp-config-sample.php which contains the fundamental sections of every file wp config . php [19659008]these:

] Something fundamental about this file is that the constants (define) and the PHP instructions come in a certain order that can not / should be changed so if you add something you do not interfere in the order of the default file.

The right place to adding more constants and functions would be just before the next line:

And, of course, do not add or modify anything below that line either, that's what the ad is for.

Next we'll go over each section of the file.

How the file is edited wp-config.php

The wp-config.php file can be edited in two fundamental ways:

  1. Automatically : Running the WordPress installation, in which case the same process will ask us for the necessary information to complete it and create it.
  2. Manually : Editing the file wp config sample . php (or doing a copy) with your favorite code editor or from the code editor of cPanel, and replacing the default data by the connection with our database and prefix (the vital). Once we have entered the data, we will save it as wp config . php . Remember to save the changes.

Database information

The most important information to add to the configuration file is the database, otherwise WordPress will not know where to store your site information. his tables, which as we saw in this article where I explained what they are and what they are for saves all your activity.

This model is the one used by the WordPress installer to complete your final file [19659336] wp config . php using the information from the database that it requests in the installation process, as in this capture:

Once the fields are completed, the following will be added to the corresponding lines in the configuration file:

And below the file is where you enter the prefix:

Once you complete the previous step of the installation, if the information that you included is correct you will be able to install WordPress. On the contrary, if you made a mistake in some data you can not connect and you will have to re-enter them correctly.

The data to be completed, to summarize, are the following:

Automatic installation

  • ] DB_NAME : The name of the database
  • DB_USER : The username with permissions for that database
  • DB_PASSWORD : The access password of the user with permissions for that database database.
  • DB_HOST : The host of your database (this information should be provided by your hosting provider, although 99% of the time it will be localhost ). If you do not know, ask your provider. Out of curiosity, here is a list of different DB_HOST you can find in some hosting providers .
  • $ table_prefix : The prefix that the tables in the database will take to distinguish them from other tables of other installations (if any) because you can use the same database for several installations.

Extra trick : If you do not get the data of your DB_HOST try to replace the default line with this one: [19659403] define ('DB_HOST', $ _ENV {DATABASE_SERVER});

define ( 'DB_HOST' $ _ENV { DATABASE_SERVER } ) ;

Manual creation

Additionally, if you manually create the wp-config.php file there are other parameters of the database that you may have to modify at times

  • DB_CHARSET : It is the default character map of your database. Normally it will be utf8 but if you have doubts ask your hosting provider. The automatic installation does not ask for it because it is defined by default in your database. If you have problems with the display of characters in your language, speak with your supplier to choose the most suitable one and change it manually.
  • DB_COLLATE : It refers to the order of the character map, and usually no parameter is added since MySQL automatically assigns it so you better not touch it, the automatic installation process does not ask for it.

Important note : NEVER use the default prefix wp_ then you will be facilitating the life to possible intruders since it is "by default". In installations that already have the prefix by default you can change it manually or with plugins .

The connection information with the database, if it was already created, is in your panel of accommodation, and in case of doubt you should consult with your hosting provider.

Otherwise you must follow these steps to create it:

Create the database in your cPanel

Go to your cPanel and access MySQL Databases

Next name your database and press the button to create it.

Create user and its database password

Creating a database in itself is nothing, it's like an empty container that nobody has access to, so you have to create a user that can access that database, as in any system, which will be what we will indicate to WordPress.

Think of it as in an excel sheet protected but without knowing the user and password to read and modify, what I say, an empty drawer, invisible and useless.

So, without leaving that MySQL screen Databases cPanel where we have created the database, we will create a new user, and his password:

Have we finished? No. If in the process of installing WordPress you put that newly created database, and the newly created user and password, you can not connect, why? Because you put information from a database, and a user with your password, but you need a vital step …

Associate the user to the database and give him privileges

Indeed. You have created the database, and you have created the user and your password, but you have not "told" MySQL that "that" user has access to "that" database, they simply exist, with no function or relationship between them.

This last step you will also do in the same screen, as you see in the following screenshot, simply choosing the user and the database of the corresponding drop-down:

As soon as you press the button " Add "will take you to the next screen, where you have to mark ALL THE PRIVILEGES and then press the button" Make changes "

If you do not, it will be as before, you would have a user who could not do anything with that database, you need to assign privileges, and if you have doubts, give them all (the detail of each privilege is for note and registration, another day we will see)

And that's it! Now we have a database and a privileged user with password (permissions) to read and write in the database.

By entering this information in our file wp – [19659005] config . php through the WordPress installer, or manually editing the file, we will be giving permission to WordPress to enter that database, with the credentials of the user that we have created, and so add the information in each table: settings, entries, comments, etc, etc, etc.

Important note : Note that the file wp-config.php is a text file, where you can read this sensitive information of the database, so it is vital that protect it from unwanted looks as we explained a long time ago .

The secret keys

In the file wp config . php you'll find a s somewhat cryptic lines called "unique authentication keys" that are neither more nor less than a security check using secret keys .

And you must use them.

To do this go to the URL that is indicated in the file: https://api.wordpress.org/ secret-key / 1.1 / salt /

And it substitutes all the lines that come for which this service of random creation of secret keys offers you, for example:

In fact, a trick to close all sessions of connected users is to change these keys because once saved the changes WordPress will (literally) your current session to all users, yours included, forcing you to log in (with your credentials) s habituales) de nuevo.


La línea incluida en el archivo wpconfig.php  por defecto para activar el modo de depuración viene inactiva por defecto, así que si queremos que WordPress nos informe de cada error mientras creamos nuestro sitio deberíamos cambiarla de false  a true , así:

Además, como ya vimos en el artículo en el que explicamos todas sus posibilidadestambién podemos añadir una línea para que se guarde un registro de todos los errores en un archivo llamado debug.log en la carpeta wp-content:

Y, si activamos el registro anterior, puede que no tenga sentido también mostrar los errores en pantalla, cosa que podrás evitar añadiendo esta otra línea:

Lo que hemos visto hasta ahora es la información más importante, y necesaria, del archivo de configuración y WordPress pueda funcionar correctamente, pero hay muchos más ajustes que podemos realizar en el archivo wpconfig.php .

Cambiar la ubicación de wp-content

También puedes añadir esta constante para cambiar la ruta donde se guarden tus plugins, temas y archivos, por supuesto poniendo tu ruta en lugar de la del e jemplo y asegurándote de que la nueva carpeta existe:

Con ruta relativa:

Con ruta absoluta:

Cambiar la ubicación de la carpeta de plugins

Si solo quieres cambiar la ubicación de la carpeta de instalación de los plugins sería algo así:

Con ruta relativa:

Con ruta absoluta:

Cambiar la ubicación de la carpeta de archivos subidos

En este caso añade algo como lo siguiente:

Migrar de dominio

Un truco poco conocido del archivo wpconfig.php  es que puede ayudarte a la hora de migrar de dominio, para lo que deberás añadir la siguiente constante antes de iniciar la migración:

Echa un vistazo a este artículo para conocer el proceso completo paso a paso.[19659765]Aumentar el límite de memoria

Un truco de los más solicitados y utilizados es modificar el límite de memoria de PHP añadiendo esta línea a wpconfig.php :

Puedes especificar el límite de memoria al que necesites: 64M, 128M, 256M. Si no funciona tendrás que hablar con tu proveedor para que te cambie el límite desde el servidor.

Aumentar el límite de memoria en la administración

Como las gestiones de administración pueden requerir mucha memoria del servidor puedes tratar de establecer el límite de tu servidor a un valor mayor así:

Desactivar XML-RPC

El protocolo XML-RPC, utilizado por plugins como JetPack para conectar con los servicios de WordPress.com, puede ser una brecha de seguridad. Si tienes claro que no lo necesitas desactívalo añadiendo el siguiente filtro tras la línea  require_once(ABSPATH . 'wp-settings.php'); :

Reparar la base de datos

Si quieres reparar manualmente la base de datos puedes hacerlo añadiendo esta línea a tu archivo wp-config.php:

A continuación visita esta URL y ejecuta la optimización: https://misitio.es/wp-admin/maint/repair.php

Cuando termines borra la anterior línea de tu archivo de configuración o cámbiala a [1 9659823]false .

Definir las rutas de tu sitio

Son varias las situaciones en las que puede ser interesante definir manualmente las rutas de tu sitio en vez de recuperarlas de la base de datos. Por ejemplo, ante un cambio erróneo en la página de ajustes generales de WordPress.

Puedes definir estas rutas en el archivo wpconfig.php  así:

Definir la ruta a tu tema

Si quieres especificar, sin lugar a dudas, cual es la ruta a tu tema activo simplemente añade una línea así:

Especificar el tema por defecto

¿Quieres que tu tema por defecto sea otro en caso de que falle el tema activo? Añade algo como el siguiente ejemplo:

Definir la ruta de la hoja de estilos

Igualmente, puedes definir la ruta a la hoja de estilos principal de tu sitio así:

Evitar que WordPress te instale un tema o plugin por defecto

Si no quieres que WordPress te instale algún tema Twentyalgo o los plugins por defecto (Hello Dolly, por ejemplo) si no los encuentra añade esta línea:

Eliminar o controlar las revisiones de entrada

Si quieres que no se guarde ninguna revisión de entradas añade lo siguiente:

Y si quieres que solo guarde un número determinado personaliza el código así:

Forzar los permisos de archivo y carpetas

Para cambiar los permisos de archivos y carpetas a sus valores por defecto – y seguros – añade esto:

Un truco muy socorrido ante estos errores es comprobar si en tu archivo wp-config.php hay algún espacio extra o línea de más antes de la apertura de PHP:  <?php

Si así fuera borra la línea o espacio y guarda los cambios.

Activar WordPress Multisitio

El primer paso para activar las funcionalidades multisitio de WordPress es añadir la siguiente línea a tu archivo wp-config.php:

Luego ve a la administración de WordPress y sigue estos pasos.

Desactivar la papelera

Si quieres borrar directamente entradas, páginas y comentarios, sin que se puedan recuperar de la papelera, añade lo siguiente:

Cambiar el periodo de vaciado de la papelera

Si quieres que la papelera de entradas, páginas y comentarios se vacíe en un periodo distinto al por defecto (30 días) modifica ese límite así:

Papelera también en los adjuntos

Por defecto WordPress no ofrece papelera de reciclaje para los archivos multimedia como si tiene para entradas, páginas o comentarios, pero puedes activarla añadiendo esta línea:

Solucionar problemas al subir archivos o crear carpetas

En ocasiones WordPress no puede crear las carpetas automáticas por mes y año de tus archivos subidos o da errores HTTP al intentar subir archivos. Una posible solución es añadir esta línea:

Usar JetPack sin conexión a WordPress.com

Si quieres usar JetPack en modo desarrollador añade lo siguiente a tu wpconfig.php :

Desactivar todas las actualizaciones automáticas en segundo plano

Sencillo, añade esto y WordPress no volverá a actualizarse solo:

Actualizaciones automáticas también a versiones mayores

Si, por el contrario, quieres que WordPress se actualice solo también a versiones mayores (de 4.7 a 4.8 por ejemplo) añade lo siguiente:

Eliminar las versiones guardadas de imágenes editadas

Por si no lo sabías, cuando editas una imagen WordPress guarda las distintas versiones por si quieres restaurarlas. Si no quieres que pase esto añade la siguiente línea:

Forzar SSL en el acceso y la administración

Si tienes un certificado SSL puedes forzar que el acceso y la navegación por la administración siempre sea bajo HTTPS así:

Solucionar el bucle de redirecciones de acceso en multisitio

A veces pasa, si no puedes acceder y entras en bucle en un WordPress Multisitio añade estas líneas:

Cargar solo lo fundamental de WordPress

Hay un modo minimalista de cargar WordPress con funcionalidades básicas que se activa añadiendo esta línea:

Evitar que WordPress te pida credenciales FTP para instalar o actualizar

En algunos servidores WordPress no puede acceder automáticamente para actualizar o instalar. Si te pasa puedes usar este código, personalizándolo con tus credenciales:

Cambia el intervalo del guardado automático

Como ya sabrás, el editor de WordPress guarda tus escritos cada poco tiempo. Si quieres cambiarlo pon el siguiente parámetro en los segundos que quieras, en el ejemplo 300 segundos=5 minutos:

Mismos usuarios en varios sitios distintos

Como puedes usar una misma base de datos para varios sitios, si quieres usar la misma tabla de usuarios para ambos puedes especificar en el archivo wpconfig.php  de cada sitio qué tablas de usuarios usar de cualquiera de ellos así:

Activar la caché de objetos de WordPress

Antes de liarte a instalar plugins de caché puedes usar la caché de objetos de caché activándola en tu archivo de configuración así:

Comprimir los contenidos

Otra funcionalidad que puedes activar en WordPress y así ahorrarte un plugin de optimización web es la posibilidad de comprimir todo tu contenido en archivos estáticos añadiendo estas líneas a tu fichero wpconfig.php :

Estas líneas comprimen el CSS y los archivos JavaScript, concatenan todos los JavaScript y fuerzan la carga de la compresión gzip, ahí es nada, sin plugins y casi sin manos.

Solucionar las entradas programadas que no se publican

Si programas entradas y no se publican cuando debieran puedes usar un cron alternativo añadiendo esta línea:

Desactivar o controlar el cron de WordPress

Por otra parte, si no vas a utilizarlo, puedes desactivar el cron de WordPress:

Y si lo prefieres puedes especificar el tiempo de espera en segundos entre cada ejecución como en este ejemplo:

Definir el dominio de cookies

También puedes especificar el dominio de las cookies de WordPress si, por ejemplo, sirves contenido estático en un subdominio y quieres definir las cookies de WordPress solo para el contenido no estático, y así evitar la carga de cookies en cada petición de contenido estático en tu subdominio.

Se haría así:

Bloquear peticiones desde URLs externas

Si quieres que se bloquee toda petición desde una URL diferente a la de tu base de datos añade la siguiente línea:

Ahora bien, si quieres permitir peticiones de URLs concretas deberías añadir una línea así:

Desactivar el editor interno de WordPress de plugins y temas

Una medida básica – e importante – que siempre recomiendo es hacer desaparecer el editor interno de WordPress de plugins y temas añadiendo esta línea:

Desactivar las actualizaciones e instalaciones de plugins y temas

Otro de mis trucos favoritos es evitar que nadie, ni siquiera los administradores, puedan actualizar o instalar temas o plugins desde la administración de WordPress, así:

Espero que aprendas mucho de este artículo y que te sirva de algo cuando lo necesites, solo con que te salve de alguna situación embarazosa me daré por satisfecho.

Si quieres ampliar aún más información sobre wpconfig.php  te recomiendo estos enlaces:


Puede que también te ayude: