Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Come modificare il file wp-config.php in WordPress (passo dopo passo)

Abbiamo modificato il file “wp-config.php” innumerevoli volte durante l’impostazione di caratteristiche avanzate, la correzione di problemi di connessione al database o la semplificazione dello sviluppo locale.

È uno di quei file che si finisce per elaborare in corso d’opera ogni volta che si ha bisogno di scavare un po’ più a fondo nel funzionamento di WordPress. E una volta che si sa dove guardare, l’elaborazione in corso è piuttosto semplice.

Questo file controlla alcune delle impostazioni più importanti del sito, come l’accesso al database, la modalità di debug e le chiavi di sicurezza. È come un pannello di controllo nascosto che fa funzionare il sito senza problemi.

In questa guida vi mostreremo come trovare e modificare in modo sicuro il file `wp-config.php` utilizzando diversi strumenti. Sarete in grado di apportare le modifiche necessarie senza preoccuparvi di rompere qualcosa.

Editing the wp-config.php file in WordPress

Ecco un elenco degli argomenti in copertina in questa guida:

Cos’è il file wp-config.php?

Il file `wp-config.php` è una parte importante di ogni sito WordPress ospitato all’esterno. Contiene impostazioni importanti che aiutano WordPress a connettersi al database e a funzionare senza problemi.

Questo file non è incluso nel download predefinito di WordPress. Viene creato automaticamente durante il processo di installazione, quando si inseriscono i dati del database.

WordPress database settings during installation

Senza le informazioni corrette in questo file, il sito non sarà in grado di connettersi al database. In questo caso si potrebbe vedere il temuto messaggio “errore nello stabilire una connessione al database”.

Oltre ai dettagli del database, questo file può includere anche impostazioni per il debug, chiavi di sicurezza, limiti di memoria e altro ancora. Le copriremo più avanti nell’articolo.

La maggior parte delle persone non ha bisogno di toccare il file `wp-config.php molto spesso. Ma sapere come funziona e come modificarlo in modo sicuro vi permette di avere un maggiore controllo sul vostro sito WordPress.

Se siete qui, probabilmente siete pronti ad apportare una modifica. Vi illustreremo il modo più sicuro per modificare questo file senza causare problemi.

💡 Non siete sicuri di voler rischiare di rompere il vostro sito?

Se vi sentite bloccati o nervosi, approfittate della nostra Assistenza WordPress di emergenza. Con una piccola spesa, i nostri ingegneri WordPress applicheranno le modifiche per voi senza interrompere il vostro sito web e i vostri clienti.

Creare un backup prima di modificare wp-config.php 💾

Il file `wp-config.php` controlla parti fondamentali del vostro sito WordPress e anche un piccolo errore in esso può mettere il vostro sito offline.

Per questo motivo consigliamo sempre di creare un backup completo di WordPress prima di apportare qualsiasi modifica.

Un backup mantiene al sicuro i contenuti, le impostazioni e i file e consente di ripristinare tutto se qualcosa va storto.

Il modo migliore per eseguire il backup di WordPress è utilizzare Duplicator. È la nostra soluzione preferita e il miglior plugin per il backup di WordPress per la maggior parte degli utenti. È possibile eseguire il backup del sito in pochi clic.

Is Duplicator the right backup and migration plugin for you?

Nota: Duplicator è disponibile anche in versione gratuita. Per caratteristiche come i backup programmati e l’archiviazione su cloud, si consiglia il piano a pagamento.

Perché consigliamo Duplicator?

Raccomandiamo Duplicator perché lo usiamo sui nostri siti web, compreso WPBeginner, per i backup. Ha cambiato le carte in tavola per la sicurezza e la stabilità dei nostri siti web. Per maggiori dettagli, date un’occhiata alla nostra recensione completa di Duplicator.

Come accedere e modificare il file wp-config.php in modo sicuro

Il file `wp-config.php` è ospitato sul server di hosting di WordPress, proprio nella cartella principale del sito.

È possibile accedervi collegandosi al proprio sito con un client FTP o con il File Manager del pannello di controllo dell’host.

Di solito preferiamo l’FTP per avere un maggiore controllo. Su Windows, strumenti come FileZilla, WinSCP o SmartFTP funzionano bene. Gli utenti Mac possono provare FileZilla, Transmit o CyberDuck.

Iniziate collegandovi al vostro sito con il vostro client FTP. Avrete bisogno dei vostri dati di accesso FTP, che vi verranno forniti dal vostro fornitore di hosting. Se non li conoscete, chiedete al team di assistenza del vostro host.

Una volta collegati, aprire la cartella principale. Vedrete altre cartelle come wp-content, wp-includes e wp-admin: è qui che risiede `wp-config.php`.

Download wp-config.php file to your computer for editing

Fare clic con il tasto destro del mouse sul file e scegliere “Scarica” per salvarlo sul computer.

Quindi, aprire il file con un editor di testo come Notepad o TextEdit. Noi li abbiamo usati entrambi e funzionano benissimo per le modifiche più semplici.

Dopo aver apportato le modifiche, tornare al client FTP e caricare il file nella stessa cartella sul server.

Il client FTP chiederà se si desidera sovrascrivere il file esistente. Scegliere “Sovrascrivi” e fare clic su OK per terminare l’uploader.

Overwrite old file

Capire il file wp-config.php

Prima di iniziare, esaminiamo il codice completo del file predefinito wp-config.php. Potete anche vedere un esempio di questo file qui.

<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the installation.
 * You don't have to use the website, you can copy this file to "wp-config.php"
 * and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * Database settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
 *
 * @package WordPress
 */

// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );

/** Database username */
define( 'DB_USER', 'username_here' );

/** Database password */
define( 'DB_PASSWORD', 'password_here' );

/** Database hostname */
define( 'DB_HOST', 'localhost' );

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

/**#@+
 * Authentication unique keys and salts.
 *
 * Change these to different unique phrases! You can generate these using
 * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
 *
 * You can change these at any point in time to invalidate all existing cookies.
 * This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define( 'AUTH_KEY',         'put your unique phrase here' );
define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
define( 'NONCE_KEY',        'put your unique phrase here' );
define( 'AUTH_SALT',        'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
define( 'NONCE_SALT',       'put your unique phrase here' );

/**#@-*/

/**
 * WordPress database table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'wp_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 *
 * @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
 */
define( 'WP_DEBUG', false );

/* Add any custom values between this line and the "stop editing" line. */



/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
	define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

Ogni sezione del file wp-config.php è ben documentata nel file stesso. Quasi tutte le impostazioni sono definite utilizzando costanti PHP.

define( 'constant_name' , 'value');

Diamo un’occhiata più da vicino a ciascuna sezione del file wp-config.php.

Impostazioni MySQL nel file wp-config.php

Le impostazioni di connessione al database di WordPress appaiono nella sezione “Impostazioni del database” del file wp-config.php.

Per completare questa sezione sono necessari l’host MySQL, il nome del database, il nome utente del database e la password.

// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );

/** Database username */
define( 'DB_USER', 'username_here' );

/** Database password */
define( 'DB_PASSWORD', 'password_here' );

/** Database hostname */
define( 'DB_HOST', 'localhost' );

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

Ecco un elenco delle costanti di questa sezione e delle loro funzioni.

Constant NameDescription
DB_NAMEThe name of the database for WordPress.
DB_USERThe username used to access the WordPress database.
DB_PASSWORDThe password for the database username.
DB_HOSTThe hostname of the database server (usually ‘localhost’).
DB_CHARSETThe hostname of the database server (usually ‘localhost’).
DB_COLLATEThe collation type for the database (usually left blank).

Per compilare questi valori, sono necessarie le informazioni sul database, che si possono trovare nel pannello di controllo del proprio account di web hosting.

A seconda del fornitore di hosting, il pannello di controllo potrebbe avere un aspetto leggermente diverso dagli screenshot qui sotto. In questo caso, è necessario cercare la sezione “Database” nel proprio account di hosting.

Ad esempio, se si utilizza Bluehost, occorre innanzitutto effettuare l’accesso al proprio account di hosting. Quindi, fate clic su “Impostazioni” sotto il vostro sito web.

Bluehost site settings

Questo mostrerà diverse impostazioni per il vostro sito web.

Passare alla scheda Avanzate e poi fare clic su “Gestisci” accanto alla sezione “cPanel”.

Bluehost advanced cPanel

Si aprirà l’interfaccia di cPanel in una nuova scheda del browser.

Da qui è necessario scorrere fino alla sezione Database e fare clic su “Database MySQL”.

MySQL database in cPanel

Nella pagina Database MySQL, troverete l’elenco del vostro database attuale, il nome utente e la password.

Se non riuscite a trovare il database di WordPress o il nome utente e la password di MySQL, dovete contattare il vostro host.

Cosa sono DB_CHARSET e DB_COLLATE nel file wp-config.php?

L’impostazione “DB_CHARSET” specifica il set di caratteri per le tabelle del database di WordPress. Il predefinito è utf8, che supporta la maggior parte delle lingue e garantisce un’ampia compatibilità.

L’impostazione “DB_COLLATE” definisce come il database ordina e confronta i caratteri.

Si consiglia di lasciarlo vuoto e lasciare che MySQL utilizzi il collage predefinito per il set di caratteri specificato (utf8_general_ci per utf8).

Autenticazione Chiavi e Sali unici

Lechiavi e i sali di autenticazione sono caratteristiche di sicurezza presenti nel file wp-config.php. Aggiungono una protezione supplementare all’installazione di WordPress, garantendo una forte crittografia delle informazioni memorizzate nei cookie degli utenti.

/**#@+
 * Authentication unique keys and salts.
 *
 * Change these to different unique phrases! You can generate these using
 * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
 *
 * You can change these at any point in time to invalidate all existing cookies.
 * This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define( 'AUTH_KEY',         'put your unique phrase here' );
define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
define( 'NONCE_KEY',        'put your unique phrase here' );
define( 'AUTH_SALT',        'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
define( 'NONCE_SALT',       'put your unique phrase here' );

/**#@-*/

In totale ci sono otto chiavi e sali diversi. Ogni coppia di chiavi e sali è una lunga stringa casuale di numeri e caratteri speciali.

Ecco le funzioni di ciascun tasto:

Constant NameDescription
AUTH_KEYAuthenticate cookies and ensure data integrity.
SECURE_AUTH_KEYSecure the authentication cookie when using SSL.
LOGGED_IN_KEYValidate logged-in cookies.
NONCE_KEYProtect nonces (numbers used once) from being guessed.
AUTH_SALTAdds extra security to the authentication process.
SECURE_AUTH_SALTAdds extra security to the authentication process.
LOGGED_IN_SALTAdds extra security to the logged-in process.
NONCE_SALTAdds extra security to the nonce creation and verification process.

Potete generare nuove chiavi visitando il generatore di chiavi segrete di WordPress.org. Potete anche modificarle in seguito se sospettate che qualcuno stia tentando di accedere alla vostra area di amministrazione di WordPress.

Per maggiori informazioni, date un’occhiata alla nostra guida sulle chiavi di sicurezza di WordPress.

Prefisso della tabella del database WordPress

Di default, WordPress aggiunge il prefisso “wp_” a tutte le tabelle che crea nel database.

Si consiglia di modificare il prefisso della tabella del database di WordPress con qualcosa di casuale durante l’installazione.

Questo renderà difficile per gli hacker indovinare le tabelle di WordPress e vi salverà da alcuni comuni attacchi SQL injection.

/**
 * WordPress database table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'wp_';

Importante ⚠️: Si noti che non è possibile modificare questo valore per un sito WordPress esistente. Per modificare queste impostazioni su un sito WordPress esistente, seguite le istruzioni contenute nel nostro articolo su come modificare il prefisso del database WordPress.

Modalità di debug di WordPress

Questa impostazione è particolarmente utile per gli utenti che stanno imparando a sviluppare WordPress o a risolvere gli errori.

Di default, WordPress nasconde gli avvisi generati da PHP durante l’esecuzione del codice. Basta impostare la modalità di debug su “true” per visualizzare questi avvisi.

Questo fornisce informazioni cruciali agli sviluppatori per trovare i bug. È anche utile se si sta cercando di risolvere i problemi su un sito WordPress.

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 *
 * @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
 */
define( 'WP_DEBUG', false );

In alternativa, si può anche scegliere di tenere un registro degli errori e degli avvisi.

Per istruzioni più dettagliate, selezionate il nostro tutorial su come abilitare la modalità di debug in WordPress.

Impostazione del percorso assoluto

La parte finale del file wp-config definisce il percorso assoluto. Questa istruzione indica a WordPress dove trovare i file principali di WordPress.

Dopo questa istruzione, l’ABSPATH viene utilizzato per caricare il file wp-settings.php.

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
	define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

Entrambe le impostazioni non devono essere modificate.

Per capire come WordPress carica i file, date un’occhiata alla nostra spiegazione su come WordPress funziona dietro le quinte. Vi fornirà una descrizione passo per passo del funzionamento del software di base di WordPress.

Trucchi e impostazioni utili di wp-config.php

Finora abbiamo coperto le impostazioni predefinite di wp-config.php. Ora esaminiamo alcune impostazioni aggiuntive.

Queste impostazioni sono facoltative e possono essere utilizzate quando necessario. Possono aiutare a risolvere gli errori e a risolvere molti errori comuni di WordPress.

Modificare la porta e i socket di MySQL in WordPress

Se il vostro fornitore di hosting WordPress utilizza porte alternative per l’host MySQL, dovrete modificare il valore DB_HOST per includere il numero di porta.

Nota: non si tratta di una nuova riga, ma di modificare il valore DB_HOST esistente.

define( 'DB_HOST', 'localhost:5067' );

Non dimenticate di modificare il numero di porta 5067 con il numero di porta fornito dal vostro host.

Se il vostro host utilizza socket e pipe per MySQL, dovrete aggiungerlo in questo modo:

define( 'DB_HOST', 'localhost:/var/run/mysqld/mysqld.sock' );

Modificare gli URL di WordPress utilizzando il file wp-config.php

Potrebbe essere necessario modificare gli URL di WordPress quando si sposta un sito WordPress su un nuovo dominio.

È possibile modificare questi URL visitando la pagina Impostazioni ” Generale.

Check your WordPress and site address from the WordPress admin

È anche possibile modificare questi URL utilizzando il file wp-config.php. Questo è utile se non riuscite ad accedere all’area di amministrazione di WordPress a causa dell’errore too many directs.

È sufficiente aggiungere queste due righe al file wp-config.php:

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

Non dimenticate di sostituire example.com con il vostro dominio.

È inoltre necessario tenere presente che i motori di ricerca trattano www.example.com e example.com come due siti diversi (vedere www vs non-www – Quale è meglio per la SEO?).

Se il sito è indicizzato con un prefisso www, è necessario aggiungere il nome del dominio di conseguenza.

Modificare la directory degli uploader usando il file wp-config.php

In modo predefinito, WordPress memorizza tutti i caricamenti dei media nella directory/wp-content/uploads/.

Se si desidera memorizzare i file dei media in una posizione diversa, è possibile aggiungere questa riga di codice nel file wp-config.php:

define( 'UPLOADS', 'wp-content/media' );

Si noti che il percorso della directory uploader è relativo all’ABSPATH impostato automaticamente in WordPress. L’aggiunta di un percorso assoluto non funzionerà.

Per ulteriori informazioni, consultate la nostra guida dettagliata su come modificare il percorso predefinito per l’uploader dei media in WordPress.

Disabilitare gli aggiornamenti automatici in WordPress

WordPress è abilitato per default agli aggiornamenti automatici. Questo permette ai siti WordPress di aggiornarsi automaticamente quando è disponibile un aggiornamento minore.

Ad esempio, se il vostro sito utilizza WordPress 6.6 e viene rilasciato un aggiornamento di sicurezza 6.6.1, WordPress installerà automaticamente l’aggiornamento.

Tuttavia, quando WordPress 6.7 sarà in versione, vi verrà chiesto di avviare l’aggiornamento.

Sebbene gli aggiornamenti automatici siano fondamentali per la sicurezza, molti utenti temono che possano anche danneggiare il sito web, rendendolo inaccessibile.

L’aggiunta di questa singola riga di codice al file wp-config.php disabilita tutti gli aggiornamenti automatici sul sito WordPress:

define( 'WP_AUTO_UPDATE_CORE', false );

Per maggiori informazioni, consultate il nostro tutorial su come disabilitare gli aggiornamenti automatici in WordPress.

Limitare le revisioni delle pubblicazioni in WordPress

WordPress è dotato di salvataggio automatico e revisioni integrate. Consultate il nostro tutorial su come annullare le modifiche in WordPress con le revisioni delle pubblicazioni.

Le revisioni occupano poco spazio sulla maggior parte dei siti web. Tuttavia, abbiamo notato un aumento significativo delle dimensioni del backup del database per alcuni dei nostri siti web più grandi.

Se si gestisce un sito web di grandi dimensioni, è possibile limitare il numero di revisioni da mantenere nel database.

È sufficiente aggiungere questa riga di codice al file wp-config.php per limitare il numero di revisioni memorizzate per una pubblica:

define( 'WP_POST_REVISIONS', 3 );

Sostituire 3 con il numero di revisioni che si desidera memorizzare.

WordPress ora scarterà automaticamente le revisioni più vecchie. Tuttavia, le revisioni dei post più vecchi sono ancora memorizzate nel database. Consultate il nostro tutorial su come eliminare le vecchie revisioni dei post in WordPress.

Video tutorial

Se volete vedere una guida più visiva, date un’occhiata al nostro tutorial su YouTube qui sotto:

Subscribe to WPBeginner

I prossimi passi per potenziare le vostre competenze su WordPress

Ora che sapete come modificare il file `wp-config.php`, potreste essere curiosi di sapere cos’altro potete modificare per rendere il vostro sito ancora migliore. Abbiamo raccolto alcuni dei nostri tutorial preferiti per aiutarvi a continuare a esplorare e ad affinare le vostre capacità.

Ognuno di essi copre consigli pratici che abbiamo utilizzato noi stessi nella gestione di siti WordPress:

Speriamo che questo articolo vi abbia aiutato a capire come modificare il file wp-config.php in WordPress e tutte le cose interessanti che potete fare con esso. Potreste anche leggere il nostro articolo sulla protezione con password della directory di amministrazione di WordPress o i nostri suggerimenti per l’utilizzo della barra di amministrazione di WordPress.

Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per le esercitazioni video su WordPress. Potete trovarci anche su Twitter e Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

58 commentiLeave a Reply

  1. Sean Hodge

    I believe you should not put any custom rules below the ABSPATH / vars bit down at the bottom, but can you put stuff in any order above those lines?

    I’ve got some time on my hands, so I’ve been doing just that, moving stuff around the wp-config file, and removing all the extra fluff between comments. I now know what it all does, and have just left a simple title above each group of rules, such as

    /**
    * Authentication Unique Keys and Salts.
    */

    All the rest of the info about Salts, and debugging etc, is now gone, the stuff that usually appears in green.

    What I also did was move the $table_prefix above the Salts, right under the rest of the database info.

    I’ve done this all because when I do go in there to modify actual rules, I have to wade my way through what is now useless info, to me.

    So far, nothing has exploded, but I thought to ask anyway.

    • WPBeginner Support

      You can change the order of the other content in that file if you wanted, we would warn to be careful when moving that you don’t remove part of the code and normally you should not need to edit your wp-config file.

      Admin

  2. Priyanshu Nandi

    Which code lines l have to type to increase
    Max_input_vars value in this file

    • WPBeginner Support

      That would require changes to your htaccess or a different file, we would recommend reaching out to your host for assistance with what you’re wanting to do.

      Admin

  3. WPBeginner Support

    Thank you, glad you liked our article :)

    Admin

  4. S.s. Brar

    Great article. A must have information for WP admins.
    Thanks to Syed and His Team.

    • WPBeginner Support

      Glad our article could be helpful :)

      Admin

  5. Mister No

    Hi there, great article. I’m having a problem with my website mobile version. When I try to open it on the mobile phone it says “This site is experiencing technical difficulties”.
    What should I do to make my site work again properly?
    Thanks in advance

  6. Paul

    Syed, all of a sudden, I can’t upload images (message: missing a temporary folder). Tried to log into WordPress to check support blogs and my username is not recognised.

  7. Gale

    I am a newbie at wordpress. I uploaded the files via Filezilla and got everything configured. Now how exactly do I actually access my new wp-blog site?

    Wp is in the root (public_html) of my website. There were several other file folders that came with Wp. Do I upload them into the public_html folder as well?

  8. Esther

    Hi, I found out when I was installing WordPress, it was installed in subdirectory Wp and has a result my website can’t go live, my web host said I have to uninstall and install again and I should leave the Wp in the Installation panel blank, my problem is that I have designed the website only to go live and once I uninstall everything will be wiped off, what do I about it, Is there a way to avoid that?

  9. Mina

    Hi,
    Thank you for the useful article.
    I’m new to this file and I have a basic question. I changed the cache plugin of my site and I need to change the line about it at the beginning of the file to override details of the previous plugin.
    Once my file is updated, can I upload it while the cache plugin is activated, and deactivate/reactivate it just after, or do I have to deactivate the plugin before uploading the new wp-config file ?
    Thanks for your help.

    • WPBeginner Support

      If your plugin is requiring you to edit your wp-config file you would normally want to edit the wp-config file before activating your new plugin.

      Admin

  10. Tiar

    hi, i have a wordpress site, i want edit my wordpress site in local, but when i already backup and run my wordpress in local. the page is full of white. can you help me ? im beginner in wordpress

  11. Arthur

    I have updated my website (lostkatanning.com) o WP 5.1 (the Gutenberg update) but now, when working on pages or posts it has slowed right down to a crawl and takes forever to respond to even a single key touch. I have tried numerous things from various websites but nothing seems to work. It is starting to do my head in! Any ideas on how to get my speed back?

  12. mostafa

    Hi
    I have a wordpress site. Today I realized my wp-config.php file has been removed for no reason (The reason is not important for me right now).

    I want to know what happens if I create another wp-config.php file in the root directory of my website by renaming the wp-config-sample.php file again and set the database name blah blah blah

    does it affect my pages and posts? How about the users who have signed up to my website? does it remove them? If the answer is yes, isn’t it better for me to restore backup? The only problem for restoring backup is that it is for two days ago and I posted a new content yesterday and I will miss it.

    Thank you very much in advance

    • WPBeginner Support

      Your user and post information is in the database so that information shouldn’t be affected, as long as you connect it to your correct database then there shouldn’t be any change.

      Admin

  13. Deepak

    Hello,
    How do I edit wp-config for setting other smtp using WP smtp plugin ?

    Plugin says, “The password is stored in plain text. We highly recommend you setup your password in your WordPress configuration file for improved security; to do this add the lines below to your wp-config.phpfile.

    define( ‘WPMS_ON’, true ); define( ‘WPMS_SMTP_PASS’, ‘your_password’ ); ”

    Where do I exactly add the code ? It don’t shown in tutorial video or article of Wpbeginner.

    • WPBeginner Support

      Hi Deepak,

      You can add this code just before the line that says ‘That’s all, stop editing! Happy blogging’ in your wp-config.php file.

      Admin

  14. Riyaz

    Thank you for sharing this article, it was simple and easy to understand.

  15. Gaurav Bhatnagar

    Hi, I just updated my WordPress to new version manually using FileZilla. My website was working. But then, I did some update inside wp-config.php file. Now the size of that file on server has become ‘0’. Even if I update it from local PC, it still remains ‘0’. What should I do? Now website is not working. I am getting – HTTP Error 500

    • WPBeginner Support

      Hi Gaurav,

      You can download a fresh copy of WordPress and extract it on your computer. Inside it you will find a wp-config-sample.php file. You can upload this file to your server and rename it to wp-config.php. You will now need to edit wp-config.php file and enter your WordPress database information.

      Admin

      • Gaurav Bhatnagar

        It worked. Thank you.

  16. Greg Bryant

    I have an intranet-based wordpress site that I’m setting up. I’m having issues with the proxy configuration in wp-config.php. I’ve tried about everything I know and I still keep getting ‘Proxy Authentication Required” errors.

    define(‘WP_PROXY_HOST’, ‘https://proxy.domain.com’);
    define(‘WP_PROXY_PORT’, ‘3128’);
    define(‘WP_PROXY_USERNAME’, ‘domain\\username’);
    define(‘WP_PROXY_PASSWORD’, ‘xxxxxx’);
    define(‘WP_PROXY_BYPASS_HOSTS’, ‘localhost’);

    Our internal wordpress site can detect that there are new versions of plug-ins but when I try to update I get the proxy authentication error. I’ve tried the variables above with https, http, just proxy.domain.com, the username escaping the \, not escaping the backslash, etc. I looked at the code in class-wp-http-proxy.php and it appears the authentication connects the username with a : and then the password like the http(s)_proxy environment variable. I’ve tried local host for the bypass and an empty string. Our Windows domain uses an file; is there a place to specify this?

    I get the same proxy authentication errors trying to download anything from the internal wordpress site.

    Error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums. (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.) in /var/www/epkb.mw-process-ctrl.com/public_html/wp-admin/includes/plugin-install.php on line 168

    I’m also having an issue with php’s file_get_contents if that’s something wordpress uses. cURL works fine.

    Any ideas?

    Thanks

      • Greg Bryant

        I have curl installed.

        It lists ipV6 as yes but I have ipV6 disabled since our network doesn’t support it.

        I think the problem is authenticating with our proxy. On the server I use:

        (the \ is escaped when setting the env variables). Above is my wp-content proxy settings.

        I’m using ufw for my firewall and have tried with it enabled & disabled with the same results.

        Any other ideas?

        Thanks

        • WPBeginner Support

          Hi Greg,

          We are not sure. You can post on WordPress.org forums may be someone who has faced similar situation can help out.

  17. Jon M

    Do the changes take effect immediately after saving the new wp-config file?

    • WPBeginner Support

      Hey Jon,

      Yes, they are effectively immediately. However, if you are editing wp-config file in a text editor on your computer, then simply saving your changes may not change the wp-config.php file on your server. You will need to upload the changed wp-config.php file back to your server for changes to take effect.

      Admin

      • Andy

        What’s the best way to upload the changed wp-config.php file back to the server?

        Can the tutorial be updated with how to upload the adjusted config file? The tutorial seems to be incomplete for the (relative) novice

        • WPBeginner Support

          Hi Andy,

          We have linked to our article on how to use FTP to upload WordPress files. It also applies to editing your wp-config.php file. You can simply download your wp-config.php file to your computer using FTP. Edit it to make your desired changes and then upload it back using the same FTP client.

          Hope this helps.

  18. ayush

    I did something silly , i removed the www part from wp site url under Setting-General . Now admin panel is getting redirected to wordpress one. i used your steps to copy both lines with modification and uploaded via ftp . No luck .Plz help

  19. Boris

    Excellent post. I am a newbie and learned a lot.

    I have an issue with my site. It looks like I have been hacked. I ran WordFence scan and it caught a line of code in my wp-config.php file that it flagged as not belonging there. Following is the code:

    My question is this. Can I remove the "@include…" from the file without screwing up the .php file.

    Any guidance will be appreciated.

    • WPBeginner Support

      Hi Boris,

      Is the file part of the core WordPress software, a plugin, or a theme? If yes, then download a fresh copy of WordPress core, plugins, or theme the file belongs to and then upload the new file.

      You can also download the file to your computer before editing the code as a backup. If anything goes wrong you can then upload it back.

      Admin

  20. Saud Razzak

    Great post, glad I read.

  21. Steph

    I’m having problems accessing site. I debugged and am getting a list of problems but most seem to come back to this one:

    “Notice: get_settings is deprecated since version 2.1.0!
    Use get_option() instead. in /usr/local/pem/vhosts/xxxxxx/webspace/siteapps/WordPress-xxxxx/htdocs/wp-includes/functions.php on line 3752″

    But line 3752 reads:
    ” trigger_error( sprintf( __(‘%1$s is deprecated since version %2$s! Use %3$s instead.’), $function, $version, $replacement ) ); ”

    So i’ve no idea what to replace. I’m sure this is 101 stuff to you, but I’m really confused!! I would really appreciate your advice, thank you.

    • Steph

      Found your section on disabling plugins – which was a great help as the the site is now viewable whilst I try to resolve. This is the message I see now when logged in WP Admin

      ” Catchable fatal error: Argument 1 passed to Genesis_Admin_CPT_Archive_Settings::__construct() must be an instance of stdClass, instance of WP_Post_Type given, called in /usr/local/pem/vhosts/xxxxxx/webspace/siteapps/WordPress-xxxxxx/htdocs/wp-content/themes/genesis/lib/admin/menu.php on line 122 and defined in /usr/local/pem/vhosts/xxxxxx/webspace/siteapps/WordPress-xxxxxx/htdocs/wp-content/themes/genesis/lib/admin/cpt-archive-settings.php on line 38 ”

      Am in a spot of bother and could really use your help – thank you!

      • WPBeginner Support

        Hey Steph,

        Try updating your Genesis child theme. Connect to your website using FTP and download your child theme as a backup. After that delete child theme folder from your website.

        Next, download a fresh copy of the theme and install it. If this doesn’t work, then try updating Genesis core itself.

        Admin

  22. Hell Men

    If i delete salt key can i decrypt wordpress password ?

  23. Sean

    Hi,
    I did something silly and now can’t get my site to work. Basically I kept my site live at said URL example.com and created a folder where I built the WordPress site example.com/Wordpress. However when I went to put the wordpress site into the root folder after backing everything up I forgot to change the site URL in the dashboard. i basically then removed my entire site and copied everything from the wordpress site into the root URL. It didn’t work – so I thought I would remove everything and restore my site as it was with both the wordpress and the normal site working.

    However once I restored all the files the wordpress site now errors with 404 Page not found and I can’t login into the dashboard either.

    Any idea how I can restore this? I think it is looking in the root directory and WordPress folder for the site or something similar and it’s causing the error – but how do I fix it?

    Thanks
    Sean

    • WPBeginner Support

      Hi Sean,

      You can update WordPress URLs by adding this code to your wp-config.php file:

      define('WP_HOME','http://example.com');
      define('WP_SITEURL','http://example.com');

      Admin

  24. Dan

    Hello i would like to have it when i upload an image it gets uploaded to my cloud from wordpress.
    i got a url & api key.
    Any suggestions would be cool. thanks.

  25. Eeswar Reddy

    Best site for WordPress Beginners. Solved my blog problem simply. Thank u so much Sir…

  26. Karl

    Nice instructions, as far as they go. However, I know it is ALSO possible to edit wp-config.php directly through WordPress’ Admin area but it seems to be a closely guarded secret as to HOW to actually do this. I do not have FTP access to my site so I have to use some other method and I’d rather not go chasing down the rabbit hole of trying out various flaky plugins until I find one that actually works. Your assistance as to what menu drill-down to explore in WordPress Admin would be greatly appreciated.

    • WPBeginner Support

      It is not a good idea to edit wp-config.php file inside WordPress admin area. One tiny mistake and you will be locked out of your WordPress site. If you do not have FTP access, you can try editing it via cPanel’s file manager.

      Admin

  27. Angela

    I don’t want to sound stupid, but please help me understand… are the wp-config.php changes supposed to be made on my Mac or on the host for my website. They are two different machines.
    Please help! I keep making changes to my web site and all of a sudden they just do not ‘take’.
    Best regards,
    Angela

    • WPBeginner Support

      You can make changes to wp-config.php file using an FTP client. It allows you to edit files on your web server. After connecting to your website using an FTP client, you need to locate wp-config.php file and download it to your computer. Make changes it to it using a text editor like TextEdit. Save your changes and then upload the file back to your web server using the FTP client.

      Admin

  28. Sharron

    Ok, so I added define(‘WP_ALLOW_REPAIR’, true); to my downloaded wp config file with notepad. Now what?

    • Ray

      Once you have done that, you can see the settings by visiting this URL on your blog:

      yoursite.com/wp-admin/maint/repair.php

      You have 2 buttons
      1st – Repair Database
      2nd – Repair and Optimize Database

      I suggest u click the 1st one and wait for the process to finish.

  29. John Johnson

    CODA is an FTP Client as well. Correct?

  30. PiNo

    Hi,

    For security I add to my .htaccess

    <files wp-config.php>
    order allow,deny
    deny from all
    </files>

    Kind regards

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.