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

Hur man redigerar wp-config.php-filen i WordPress (steg för steg)

Under din WordPress-resa kommer du ofta att stöta på handledningar som ber dig att redigera filen ”wp-config.php”. Den här filen är viktig eftersom den kontrollerar viktiga WordPress-inställningar, vilket gör den till ett kraftfullt verktyg för att hantera din webbplats.

Under årens lopp har vi arbetat med otaliga WordPress-installationer. Denna erfarenhet har visat oss hur viktig filen wp-config.php är, särskilt för säkerhet, prestanda och felsökning.

I den här artikeln kommer vi att lära dig hur du redigerar filen wp-config.php i WordPress. Vi kommer också att dela med oss av några av de bästa metoderna som vi har utvecklat under åren.

Editing the wp-config.php file in WordPress

Här är en lista över de ämnen som vi kommer att behandla i denna guide:

Vad är wp-config.php-filen?

Som namnet antyder är det en konfigurationsfil som är en del av alla WordPress-webbplatser med egen hosting.

Till skillnad från andra WordPress-kärnfiler levereras inte filen wp-config.php inbyggd med WordPress.

Istället genereras den uttryckligen för din webbplats under installationsprocessen.

WordPress database settings during installation

WordPress lagrar din databasinformation i filen wp-config.php. Utan denna information kommer din WordPress-webbplats inte att fungera och du kommer att fåfelmeddelandet ”error establishing database connection.

Filen wp-config.php innehåller flera andra inställningar på hög nivå utöver databasinformationen. Vi kommer att förklara dem senare i den här artikeln.

Vanliga WordPress-användare kanske inte behöver redigera filen wp-config.php så ofta. Men att förstå hur man gör det kan göra dig mer skicklig i hanteringen av din WordPress-webbplats.

Eftersom den här filen innehåller mycket känslig information rekommenderas att du inte rör den om du inte absolut inte har något annat val.

Men eftersom du läser den här artikeln måste du redigera filen wp-config.php. Nedan följer stegen för att göra det utan att röra till saker.

Videohandledning

Subscribe to WPBeginner

Om du inte gillar videon eller behöver fler instruktioner kan du fortsätta läsa.

Komma igång

Filen wp-config.php är så viktig för en WordPress-webbplats att ett litet misstag kan göra din webbplats otillgänglig.

Innan du gör några kritiska ändringar på din WordPress-webbplats bör du därför alltid skapa en fullständig WordPress-backup.

Detta säkerställer att dina WordPress-data och inställningar säkerhetskopieras och kan återställas om något går fel.

Vi rekommenderar att du använder Duplicator. Det är det bästa WordPress backup-pluginet och gör att du enkelt kan säkerhetskopiera din webbplats.

Is Duplicator the right backup and migration plugin for you?

Obs: Det finns också en gratis version av Duplicator tillgänglig. Vi rekommenderar dock att du uppgraderar till den betalda planen för att låsa upp fler funktioner.

Åtkomst till och redigering av filen wp-config.php

Filen wp-config.php finns på din WordPress-hostingserver.

Du kommer åt den genom att ansluta din webbplats med hjälp av en FTP-klient eller appen File Manager i kontrollpanelen för ditt webbhotellskonto.

Med en FTP-klient kan du överföra filer mellan en server och din dator. Windows-användare kan installera FileZilla, WinSCP eller SmartFTP, medan Mac-användare kan välja mellan FileZilla, Transmit eller CyberDuck.

Först måste du ansluta till din webbplats med hjälp av en FTP-klient. Du behöver FTP-inloggningsuppgifter, som du kan få från ditt webbhotell. Om du inte vet vilka FTP-inloggningsuppgifter du har kan du kontakta supportteamet hos din hostingleverantör.

Filen wp-config.php ligger vanligtvis i rotmappen på din webbplats tillsammans med andra mappar som wp-includes, wp-content och wp-admin.

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

Högerklicka bara på filen och välj ”Download” i menyn.

Din FTP-klient kommer nu att ladda ner filen wp-config.php till din dator. Du kan öppna och redigera den med hjälp av en vanlig textredigeringsapp som Notepad eller Text Edit.

När du är klar med redigeringen kan du enkelt ladda upp den till din webbplats med hjälp av FTP.

Du kommer då att se ett meddelande om att filen redan finns med en massa alternativ. Välj ”Skriv över” och klicka på ”OK”.

Overwrite old file

Förstå filen wp-config.php

Innan du börjar, låt oss undersöka den fullständiga koden för standardfilen wp-config.php. Du kan också se ett exempel på denna fil här.

<?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';

Varje avsnitt i filen wp-config.php är väl dokumenterat i själva filen. Nästan alla inställningar här definieras med hjälp av PHP-konstanter.

define( 'constant_name' , 'value');

Låt oss ta en närmare titt på varje avsnitt i filen wp-config.php.

MySQL-inställningar i wp-config.php-filen

Inställningarna för din databasanslutning i WordPress finns i avsnittet ”Database Settings” i filen wp-config.php.

Du behöver din MySQL-värd, databasnamn, databasanvändarnamn och lösenord för att fylla i det här avsnittet.

// ** 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', '' );

Här följer en lista över konstanterna i detta avsnitt och vad de gör.

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).

För att fylla i dessa värden behöver du databasinformation, som du hittar i kontrollpanelen på ditt webbhotellskonto.

Beroende på din hostingleverantör kan din kontrollpanel se något annorlunda ut än skärmdumparna nedan. I så fall måste du leta efter avsnittet ”Databaser” i ditt värdtjänstkonto.

Om du till exempel använder Bluehost loggar du först in på ditt värdkonto. Klicka sedan på ”Inställningar” under din webbplats.

Bluehost site settings

Här visas olika inställningar för din webbplats.

Gå till fliken Avancerat och klicka sedan på ”Hantera” bredvid avsnittet ”cPanel”.

Bluehost advanced cPanel

Det öppnar cPanel-gränssnittet i en ny webbläsarflik.

Härifrån måste du bläddra till avsnittet Databaser och klicka på ”MySQL-databaser”.

MySQL database in cPanel

På sidan MySQL-databaser hittar du en lista över din aktuella databas, användarnamn och lösenord.

Om du inte kan hitta din WordPress-databas eller MySQL-användarnamn och lösenord måste du kontakta ditt webbhotell.

Vad är DB_CHARSET och DB_COLLATE i wp-config.php-filen?

Inställningen ”DB_CHARSET” anger teckenuppsättningen för dina WordPress-databastabeller. Standardinställningen är utf8, som stöder de flesta språk och garanterar bred kompatibilitet.

Inställningen ”DB_COLLATE” definierar hur databasen sorterar och jämför tecken.

Vi rekommenderar att du lämnar den tom och låter MySQL använda standardkollationen för den angivna teckenuppsättningen (utf8_general_ci för utf8).

Autentisering Unika nycklar och salter

Autentiseringsnycklar och salter är säkerhetsfunktioner i filen wp-config.php. De ger extra skydd till din WordPress-installation genom att säkerställa stark kryptering av information som lagras i användarcookies.

/**#@+
 * 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' );

/**#@-*/

Det finns totalt åtta olika nycklar och salter. Varje nyckel- och saltpar är en slumpmässig, lång sträng med textnummer och specialtecken.

Här följer en beskrivning av vad varje knapp gör:

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.

Du kan generera nya nycklar genom att besöka WordPress.org:s generator för hemliga nycklar. Du kan också ändra dem senare om du misstänker att någon försöker komma åt ditt WordPress-adminområde.

Mer information finns i vår guide om säkerhetsnycklar för WordPress.

WordPress databas tabellprefix

Som standard lägger WordPress till prefixet ”wp_” i alla tabeller som skapas i databasen.

Vi rekommenderar att du ändrar WordPress databasens tabellprefix till något slumpmässigt under installationen.

Detta gör det svårt för hackare att gissa sig till dina WordPress-tabeller och räddar dig från några vanliga SQL-injektionsattacker.

/**
 * 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_';

Viktigt ⚠️: Observera att du inte kan ändra detta värde för en befintlig WordPress-webbplats. Om du vill ändra dessa inställningar på en befintlig WordPress-webbplats följer du anvisningarna i vår artikel om hur du ändrar WordPress-databasprefixet.

WordPress felsökningsläge

Denna inställning är särskilt användbar för användare som lär sig WordPress-utveckling eller felsökning av fel.

Som standard döljer WordPress meddelanden som genereras av PHP när kod körs. Om du bara ställer in felsökningsläget på ”true” visas dessa meddelanden.

Detta ger viktig information för utvecklare som vill hitta buggar. Den är också till hjälp om du försöker felsöka problem på en WordPress-webbplats.

/**
 * 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 );

Alternativt kan du också välja att föra en logg över fel och anmärkningar.

Mer detaljerade instruktioner finns i vår handledning om hur du aktiverar felsökningsläget i WordPress.

Absoluta sökvägsinställningar

Den sista delen av wp-config-filen definierar den absoluta sökvägen. Denna instruktion talar om för WordPress var WordPress-kärnfilerna finns.

Efter denna instruktion används ABSPATH för att ladda filen 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';

Båda dessa inställningar är inte avsedda att ändras.

För att förstå hur WordPress laddar filer, ta en titt på vår förklarande text om hur WordPress fungerar bakom kulisserna. Den ger dig en steg-för-steg-uppdelning av hur WordPress kärnprogramvara fungerar.

Användbara wp-config.php-hack och inställningar

Hittills har vi gått igenom standardinställningarna för wp-config.php. Låt oss nu undersöka några ytterligare inställningar.

Dessa inställningar är valfria och kan användas vid behov. De kan hjälpa dig att felsöka fel och lösa många vanliga WordPress-fel.

Ändra MySQL-port och sockets i WordPress

Om din WordPress-värdleverantör använder alternativa portar för MySQL-host måste du ändra ditt DB_HOST-värde så att det inkluderar portnumret.

Observera: Det här är inte en ny rad, utan du måste redigera det befintliga DB_HOST-värdet.

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

Glöm inte att ändra portnumret 5067 till det portnummer som tillhandahålls av ditt webbhotell.

Om din host använder sockets och pipes för MySQL måste du lägga till det på det här sättet:

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

Ändra WordPress-webbadresser med hjälp av wp-config.php-filen

Du kan behöva ändra WordPress-URL:er när du flyttar en WordPress-webbplats till ett nytt domännamn.

Du kan ändra dessa webbadresser genom att besöka sidan Inställningar ” Allmänt.

Check your WordPress and site address from the WordPress admin

Du kan också ändra dessa webbadresser med hjälp av filen wp-config.php. Detta är praktiskt om du inte kan komma åt WordPress-adminområdet på grund av felet för många omdirigeringar.

Lägg bara till dessa två rader i din wp-config.php-fil:

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

Glöm inte att ersätta example.com med ditt domännamn.

Du måste också komma ihåg att sökmotorer behandlar www.example.com och example.com som två olika platser (se www vs non-www – Vilken är bäst för SEO?) .

Om din webbplats är indexerad med ett www-prefix måste du lägga till ditt domännamn i enlighet med detta.

Ändra katalog för uppladdningar med hjälp av filen wp-config.php

Som standard lagrar WordPress alla dina mediauppladdningar i katalogen/wp-content/uploads/.

Om du vill lagra dina mediefiler på en annan plats kan du lägga till den här kodraden i din wp-config.php-fil:

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

Observera att sökvägen till uppladdningskatalogen är relativ till den ABSPATH som automatiskt ställs in i WordPress. Att lägga till en absolut sökväg här kommer inte att fungera.

Se vår detaljerade guide om hur du ändrar standardplatsen för mediauppladdning i WordPress för mer information .

Inaktivera automatiska uppdateringar i WordPress

WordPress har automatiska uppdateringar aktiverade som standard. Detta gör att WordPress-webbplatser automatiskt uppdateras när en mindre uppdatering är tillgänglig.

Om din webbplats t.ex. kör WordPress 6.6 och en säkerhetsuppdatering 6.6.1 släpps, kommer WordPress automatiskt att installera uppdateringen.

När WordPress 6.7 släpps kommer du dock att bli ombedd att starta uppdateringen.

Automatiska uppdateringar är viktiga för säkerheten, men många användare är rädda för att de också kan förstöra deras webbplats och göra den otillgänglig.

Om du lägger till denna enda kodrad i din wp-config.php-fil inaktiveras alla automatiska uppdateringar på din WordPress-webbplats:

define( 'WP_AUTO_UPDATE_CORE', false );

Mer information finns i vår handledning om hur du inaktiverar automatiska uppdateringar i WordPress.

Begränsa ändringar av inlägg i WordPress

WordPress har inbyggd autosparning och revideringar. Se vår handledning om hur du ångrar ändringar i WordPress med inläggsrevisioner.

Revisioner tar upp lite utrymme på de flesta webbplatser. Vi märkte dock en betydande ökning av storleken på databasbackupen för några av våra större webbplatser.

Om du driver en stor webbplats kan du begränsa antalet revisioner som du vill behålla i databasen.

Lägg bara till den här kodraden i filen wp-config.php för att begränsa antalet lagrade revisioner för ett inlägg:

define( 'WP_POST_REVISIONS', 3 );

Ersätt 3 med det antal revisioner som du vill lagra.

WordPress kommer nu automatiskt att kassera äldre revideringar. Dina äldre inläggsrevisioner lagras dock fortfarande i din databas. Se vår handledning om hur du tar bort gamla inläggsrevisioner i WordPress.

Vi hoppas att den här artikeln hjälpte dig att lära dig hur du redigerar filen wp-config.php i WordPress och alla de coola saker du kan göra med den. Du kanske också vill läsa vår artikel om att lösenordsskydda WordPress-adminkatalogen eller våra tips för att använda WordPress-adminfältet.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Avslöjande: Vårt innehåll stöds av våra läsare. Det innebär att om du klickar på några av våra länkar, kan vi tjäna en provision. Se hur WPBeginner finansieras, varför det är viktigt, och hur du kan stödja oss. Här är vår editoriala 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.

Den ultimata WordPress-verktygslådan

Få GRATIS tillgång till vår verktygslåda - en samling WordPress-relaterade produkter och resurser som varje professionell användare bör ha!

Reader Interactions

61 kommentarerLämna ett svar

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Sean Hodge says

    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 says

      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.

      Administratör

    • WPBeginner Support says

      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.

      Administratör

  3. Mister No says

    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

  4. Paul says

    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.

  5. Gale says

    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?

  6. Esther says

    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?

  7. Mina says

    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 says

      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.

      Administratör

  8. Tiar says

    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

  9. Arthur says

    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?

  10. mostafa says

    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 says

      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.

      Administratör

  11. Deepak says

    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.

  12. Gaurav Bhatnagar says

    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 says

      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.

      Administratör

  13. Greg Bryant says

    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 says

        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 says

      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.

      Administratör

      • Andy says

        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

  14. ayush says

    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

  15. Boris says

    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 says

      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.

      Administratör

  16. Steph says

    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 says

      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 says

        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.

        Administratör

  17. Sean says

    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 says

      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');

      Administratör

  18. Dan says

    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.

  19. Karl says

    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 says

      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.

      Administratör

  20. Angela says

    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 says

      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.

      Administratör

  21. Sharron says

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

    • Ray says

      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.

  22. PiNo says

    Hi,

    For security I add to my .htaccess

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

    Kind regards

Lämna ett svar

Tack för att du väljer att lämna en kommentar. Tänk på att alla kommentarer modereras enligt våra policy för kommentarer, och din e-postadress kommer INTE att publiceras. Vänligen använd INTE nyckelord i namnfältet. Låt oss ha en personlig och meningsfull konversation.