高度な機能を設定したり、データベース接続の問題を修正したり、ローカルでの開発を容易にしたりするために、私たちは数え切れないほど「wp-config.php」ファイルを編集してきました。
WordPressがどのように動作するのか、もう少し深く知りたいときにいつも扱うことになるファイルのひとつです。どこを見ればいいのかがわかれば、作業はとても簡単です。
このファイルは、データベースアクセス、デバッグモード、セキュリティキーなど、サイトの最も重要な設定のいくつかをコントロールします。サイトをスムーズに運営するための非表示コントロールパネルのようなものです。
このガイドでは、さまざまなツールを使って`wp-config.php`ファイルを安全に見つけて編集する方法を紹介します。何かを壊す心配をすることなく、必要な変更を加えることができるようになります。

以下は、このガイドで取り上げるトピックのリストである:
- What Is the wp-config.php File?
- Create a Backup Before You Edit wp-config.php 💾
- How to Access and Edit the wp-config.php File Safely
- Understanding the wp-config.php File
- MySQL Settings in wp-config.php File
- Authentication Unique Keys and Salts
- WordPress Database Table Prefix
- WordPress Debugging Mode
- Absolute Path Settings
- Useful wp-config.php Hacks and Settings
- Changing MySQL Port and Sockets in WordPress
- Changing WordPress URLs Using wp-config.php File
- Changing Uploads Directory Using The wp-config.php File
- Disable Automatic Updates in WordPress
- Limit Post Revisions in WordPress
- Video Tutorial
- Next Steps to Power Up Your WordPress Skills
wp-config.phpファイルとは何ですか?
wp-config.php`ファイルは、すべてのインストール型のWordPressサイトの重要な部分です。WordPressがデータベースに接続し、スムーズに動作するための重要な設定を保持します。
このファイルはWordPressの初期設定には含まれていません。インストール時にデータベースの詳細を入力すると自動的に作成されます。

このファイルに正しい情報がないと、サイトはデータベースに接続できません。その時、「データベース接続の確立エラー」という恐ろしいメッセージが表示されるかもしれません。
このファイルには、データベースの詳細とともに、デバッグ、セキュリティキー、メモリ制限などの設定も含めることができる。これらについては投稿の後半で取り上げる。
ほとんどの人は、`wp-config.php`ファイルを頻繁に触る必要はありません。しかし、このファイルがどのように機能するのか、そして安全に編集する方法を知っていれば、WordPressサイトをよりコントロールできるようになります。
ここに来たということは、おそらく変更を加える準備ができたということでしょう。問題を起こさずにこのファイルを編集する最も安全な方法を説明します。
💡サイトを壊すリスクを冒すことを本当に〜してもよいですか?
もし、あなたが先頭に固定表示したり、不安に感じているなら、WordPress緊急サポートをご利用ください。少額の料金で、WordPress エンジニアがお客様のサイトやカスタマイザーに支障をきたすことなく変更を適用します。
wp-config.phpを編集する前にバックアップを作成してください。
wp-config.php`ファイルはWordPressサイトの重要な部分をコントロールしており、ちょっとしたミスでもサイトをオフラインにしてしまう可能性があります。
そのため、変更を加える前にWordPressの完全なバックアップを作成することをお勧めします。
バックアップは、コンテンツ、設定、ファイルを安全に保ち、何か問題が発生した場合にすべてを復元することができます。
WordPressをバックアップする最善の方法は、Duplicatorを使用することです。Duplicatorは私たちの一番のソリューションであり、ほとんどのユーザーにとって最高のWordPressバックアッププラグインです。数クリックでサイトをバックアップできる。

注: Duplicatorには無料版もあります。スケジュールバックアップやクラウドストレージなどの機能については、有料プランをお勧めします。
Duplicatorをお勧めする理由
私たちがDuplicatorをお勧めする理由は、WPBeginnerを含む私たち自身のサイトでバックアップのために使用しているからです。Duplicatorは私たちのサイトのセキュリティと安定性を大きく変えました。詳しくはDuplicatorのレビューをご覧ください。
wp-config.phpファイルに安全にアクセスして編集する方法
wp-config.php`ファイルはWordPressホスティングサービスサーバーのサイトルートフォルダーにあります。
FTPクライアントまたはホスティングサービスコントロールパネルのファイルマネージャを使用してサイトに接続することでアクセスできます。
私たちは通常、よりコントロールしやすいFTPを好みます。Windowsでは、FileZilla、WinSCP、SmartFTPのようなツールが効果的です。Macユーザーは、FileZilla、Transmit、CyberDuckを試してみてください。
FTPクライアントを使用してサイトに接続することから始めます。FTPログインの詳細が必要ですが、これはホスティングサービス会社からプロバイダーとして提供されます。わからない場合は、ホスティングサービスのサポートチームにお尋ねください。
接続したら、ルートフォルダーを開きます。wp-content
、wp-includes
、wp-adminなどの
フォルダーが見えますが、ここに`wp-config.php`があります。

ファイルを右クリックし、「ダウンロード」を選択してコンピューターに保存します。
次に、メモ帳やテキストエディットのようなプレーンテキストエディターでファイルを開きます。どちらも簡単な編集には最適です。
変更後、FTPクライアントに戻り、サーバーの同じフォルダーにファイルをアップロードします。
FTPクライアントが、既存のファイルを上書きするかどうかを尋ねます。上書き」を選択し、「OK」をクリックしてアップロードを終了します。

wp-config.phpファイルを理解する
始める前に、初期設定のwp-config.phpファイルの全コードを調べてみましょう。このファイルのサンプルはこちらでも見ることができます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | <?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' ; |
wp-config.phpファイルの各セクションは、ファイル自体にしっかりとドキュメンテーションされています。ここでのほとんどすべての設定は、PHP定数を使って定義されています。
1 | define( 'constant_name' , 'value' ); |
wp-config.phpファイルの各セクションを詳しく見てみよう。
wp-config.phpファイルのMySQL設定
WordPressのデータベース接続設定は、wp-config.phpファイルの「データベース設定」セクションに表示されます。
このセクションを完了するには、MySQLホスティングサービス、データベース名、データベースユーザ名、パスワードが必要です。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // ** 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' , '' ); |
以下は、このセクションの定数とその役割の一覧である。
Constant Name | Description |
---|---|
DB_NAME | The name of the database for WordPress. |
DB_USER | The username used to access the WordPress database. |
DB_PASSWORD | The password for the database username. |
DB_HOST | The hostname of the database server (usually ‘localhost’). |
DB_CHARSET | The hostname of the database server (usually ‘localhost’). |
DB_COLLATE | The collation type for the database (usually left blank). |
これらの値を入力するには、データベース情報が必要です。この情報は、ウェブホスティングアカウントのコントロールパネルで見つけることができます。
ホスティングサービスによっては、コントロールパネルが以下のスクリーンショットと若干異なる場合があります。その場合、ホスティングサービスの「データベース」セクションを探す必要があります。
例えば、Bluehostを使用している場合、まずホスティングアカウントにログインします。次に、サイトの下にある「設定」をクリックします。

あなたのサイトのさまざまな設定が表示されます。
詳細」タブに切り替え、「cPanel」セクションの横にある「管理」をクリックします。

新しいブラウザータブでcPanelインターフェースが開きます。
ここから、「データベース」セクションまでスクロールし、「MySQLデータベース」をクリックする必要がある。

MySQL Databasesのページでは、現在のデータベース、ユーザー名、パスワードのリストを見ることができます。
WordPressデータベースまたはMySQLのユーザー名とパスワードが見つからない場合は、ホスティングサービスに連絡する必要があります。
wp-config.phpファイルのDB_CHARSETとDB_COLLATEとは何ですか?
DB_CHARSET’設定は、WordPressデータベーステーブルの文字セットを指定します。初期設定はutf8で、ほとんどの言語をサポートし、幅広い互換性を保証します。
DB_COLLATE’設定は、データベースがどのように文字をソートし、比較するかを定義する。
空白のままにし、MySQL が指定された文字セットの初期照合順序(utf8 の場合は utf8_general_ci)を使用するようにすることをお勧めします。
認証 ユニーク・キーとソルト
認証キーとソルトは、wp-config.phpファイルのセキュリティ機能です。ユーザーCookieに保存された情報を強力に暗号化することで、WordPressインストーラの保護を強化します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /**#@+ * 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' ); /**#@-*/ |
キーとソルトは全部で8種類ある。各キーとソルトのペアは、数字と特殊文字のランダムな長い文字列である。
それぞれのキーの役割は以下の通り:
Constant Name | Description |
---|---|
AUTH_KEY | Authenticate cookies and ensure data integrity. |
SECURE_AUTH_KEY | Secure the authentication cookie when using SSL. |
LOGGED_IN_KEY | Validate logged-in cookies. |
NONCE_KEY | Protect nonces (numbers used once) from being guessed. |
AUTH_SALT | Adds extra security to the authentication process. |
SECURE_AUTH_SALT | Adds extra security to the authentication process. |
LOGGED_IN_SALT | Adds extra security to the logged-in process. |
NONCE_SALT | Adds extra security to the nonce creation and verification process. |
シークレットキーは、WordPress.org のシークレットキー・ジェネレータで生成できます。また、誰かが WordPress 管理エリアにアクセスしようとしていると思われる場合は、後で変更することもできます。
詳しくは、WordPressセキュリティキーのガイドをご覧ください。
WordPressデータベースのテーブル接頭辞
初期設定では、WordPressはデータベースに作成するすべてのテーブルに’wp_’接頭辞を付加します。
インストール時にWordPressデータベースのテーブル接頭辞をランダムなものに変更することをお勧めします。
これにより、ハッカーがWordPressのテーブルを推測することが難しくなり、一般的なSQLインジェクション攻撃からあなたを守ることができます。
1 2 3 4 5 6 7 | /** * 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_' ; |
重要⚠️: 既存の WordPress サイトでこの値を変更することはできません。既存のWordPressサイトでこれらの設定を変更するには、WordPressデータベースの接頭辞を変更する方法の投稿の指示に従ってください。
WordPressのデバッグモード
この設定は、WordPressの開発を学んでいるユーザーや、エラーのトラブルシューティングに特に役立ちます。
WordPressの初期設定では、コード実行時にPHPが生成する通知を非表示にしています。デバッグモードを’true’に設定するだけで、これらの通知が表示されます。
これは開発者がバグを見つけるための重要な情報を提供します。また、WordPressサイトのトラブルシューティングにも役立ちます。
1 2 3 4 5 6 7 8 9 10 11 12 13 | /** * 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 ); |
また、エラーや通知のログ記録を残すこともできる。
より詳細な手順については、WordPressでデバッグモードを有効化するチュートリアルをご覧ください。
絶対パス設定
wp-configファイルの最後の部分は、絶対パスを定義する。この命令は、WordPressにWordPressのコアファイルの場所を指示します。
この命令の後、ABSPATHはwp-settings.phpファイルをロードするために使用されます。
1 2 3 4 5 6 7 | /** 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' ; |
これらの設定はいずれも変更することはできない。
WordPressがどのようにファイルを読み込むかを理解するには、WordPressが裏でどのように動作しているかについての解説をご覧ください。WordPressのコアソフトウェアがどのように動作するのか、ステップバイステップで説明しています。
便利なwp-config.phpのハックと設定
ここまで、wp-config.phpの初期設定について説明してきました。次に、いくつかの追加設定を調べてみましょう。
これらの設定はオプションで、必要なときに使用できます。エラーのトラブルシューティングやWordPressの一般的なエラーの解決に役立ちます。
WordPressでMySQLのポートとソケットを変更する
WordPressホスティングサービスがMySQLホスティングサービスに代替ポートを使用している場合は、DB_HOSTの値にポート番号を含めるように変更する必要があります。
注:これは新規行ではなく、既存のDB_HOST値を編集する必要があります。
1 | define( 'DB_HOST' , 'localhost:5067' ); |
ポート番号5067を、ホスティングサービスが提供するポート番号に変更することをお忘れなく。
ホスティングサービスがMySQLにソケットとパイプを使用している場合は、次のように追加する必要があります:
1 | define( 'DB_HOST' , 'localhost:/var/run/mysqld/mysqld.sock' ); |
wp-config.phpファイルを使ってWordPressのURLを変更する
WordPressサイトを新しいドメイン名に移行する際、WordPressのURLを変更する必要がある場合があります。
これらのURLは、設定 ” 一般ページで変更できます。

これらのURLは、wp-config.phpファイルを使用して変更することもできます。これは、エラーが多すぎてWordPressの管理エリアにアクセスできない場合に便利です。
以下の2行をwp-config.phpファイルに追加するだけです:
1 2 | define( 'WP_HOME' , 'http://example.com' ); define( 'WP_SITEURL' , 'http://example.com' ); |
example.comをあなたのドメイン名に置き換えることをお忘れなく。
また、検索エンジンはwww.example.com、example.comを2つの異なる場所として扱うことも念頭に置いておく必要がある(www vs non-www – Which is better for SEO?を参照)。
あなたのサイトがwww接頭辞でインデックスされている場合は、それに応じてドメイン名を追加する必要があります。
wp-config.phpファイルによるアップロードディレクトリの変更
初期設定では、WordPressはすべてのメディアアップロードを/wp-content/uploads/ディレクトリに保存します。
メディアファイルを別の場所に保存したい場合は、wp-config.phpファイルに次のコードを追加してください:
1 | define( 'UPLOADS' , 'wp-content/media' ); |
アップロードディレクトリのパスは、WordPressで自動的に設定されるABSPATHからの相対パスであることに注意してください。ここに絶対パスを追加しても動作しません。
詳しくは、WordPressでメディアアップロードの初期設定を変更する方法の詳細ガイドをご覧ください。
WordPressの自動更新を無効化する
WordPressは初期設定で自動更新が有効になっています。これにより、WordPressサイトはマイナーアップデートが利用可能になると自動的に更新されます。
例えば、あなたのサイトがWordPress 6.6を使用していて、セキュリティアップデート6.6.1がリリースされた場合、WordPressは自動的にアップデートをインストールします。
しかし、WordPress 6.7がリリースされると、更新を開始するよう求められます。
自動更新はセキュリティ上重要であるが、多くのユーザーは、自動更新によってサイトが壊れてアクセスできなくなることを恐れている。
この個別コードをwp-config.phpファイルに追加すると、WordPressサイトの自動更新がすべて無効化されます:
1 | define( 'WP_AUTO_UPDATE_CORE' , false ); |
詳しくはWordPressの自動更新を無効化する方法のチュートリアルをご覧ください。
カテゴリー:WordPressで投稿のリビジョンを制限する
WordPressには自動保存とリビジョンがビルトインされています。投稿リビジョンでWordPressの変更を元に戻す方法については、チュートリアルをご覧ください。
リビジョンはほとんどのサイトでほとんど容量を消費しません。しかし、いくつかの大規模サイトでは、データベースのバックアップサイズが大幅に増加していることに気づきました。
大規模なサイトを運営している場合は、データベースに保存するリビジョン数を制限することができます。
このコードをwp-config.phpファイルに追加するだけで、投稿の保存リビジョン数を制限することができます:
1 | define( 'WP_POST_REVISIONS' , 3 ); |
3を保存したいリビジョン数に置き換えてください。
WordPressは古いリビジョンを自動的に破棄するようになりました。しかし、過去の投稿リビジョンはまだデータベースに保存されています。WordPressで古い投稿リビジョンを削除する方法については、チュートリアルをご覧ください。
動画チュートリアル
より視覚的なチュートリアルをご覧になりたい方は、以下のYouTubeチュートリアルをご覧ください:
WordPressスキルアップのための次のステップ
さて、`wp-config.php`ファイルを編集する方法はお分かりいただけたと思いますが、サイトをより良くするために他にどのような調整ができるのか気になりますよね。私たちのお気に入りのチュートリアルをいくつかまとめましたので、どんどん調べてスキルを磨いてください。
それぞれ、WordPressサイトを管理する中で私たち自身が使ってきた実践的なヒントを取り上げています:
- WP-ConfigでWordPressのエラーログを設定する方法
- WordPress Tips、トリック、ハックの最重要項目
- WordPressで最も役立つ.htaccessのトリック
- WordPressのキーボードショートカットで時間を節約しよう
この投稿がWordPressのwp-config.phpファイルを編集する方法と、それを使ってできるすべてのクールなことを学ぶのに役立てば幸いです。WordPress 管理ディレクトリのパスワード保護に関する投稿やWordPress 管理バーの使い方のヒントもご覧ください。
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.
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
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
WPBeginner Support
Thank you, glad you liked our article
Admin
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
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
WPBeginner Support
There are a few possible reasons you could be receiving that error, for a starting point you would want to take a look at our guide here: https://www.wpbeginner.com/beginners-guide/beginners-guide-to-troubleshooting-wordpress-errors-step-by-step/
Admin
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.
WPBeginner Support
For that error, you would want to take a look at our guide here: https://www.wpbeginner.com/wp-tutorials/how-to-fix-missing-a-temporary-folder-error-in-wordpress/
Admin
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?
WPBeginner Support
If you’re installing WordPress using FTP then you would want to take a look at our guide here:
https://www.wpbeginner.com/how-to-install-wordpress/#installftp
Once the site is set up you would want to go to your login page and log in with the user you created in the installation process:
https://www.wpbeginner.com/beginners-guide/how-to-find-your-wordpress-login-url/
Admin
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?
WPBeginner Support
If your host requires the site to be in the main directory, you would want to follow the steps in the WordPress coded to move directories on your existing server
Admin
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
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
WPBeginner Support
For moving your live site to a local installation, you would want to use the guide here: https://www.wpbeginner.com/wp-tutorials/how-to-move-live-wordpress-site-to-local-server/
Admin
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?
WPBeginner Support
Hi Arthur,
You can disable the Gutenberg by installing the classic editor plugin to temporarily solve the problem.
Admin
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
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
Riyaz
Thank you for sharing this article, it was simple and easy to understand.
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.
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
WPBeginner Support
Hi Greg,
Please make sure that your localhost environment has curl extension installed and enabled for PHP. Please see our guide on how to fix secure connection error in WordPress for more details.
Admin
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.
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.
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
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
Saud Razzak
Great post, glad I read.
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
Hell Men
If i delete salt key can i decrypt wordpress password ?
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
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.
Eeswar Reddy
Best site for WordPress Beginners. Solved my blog problem simply. Thank u so much Sir…
WPBeginner Support
You are welcome
Don’t forget to join us on Twitter for more WordPress tips and tutorials.
Admin
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
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
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.
John Johnson
CODA is an FTP Client as well. Correct?
PiNo
Hi,
For security I add to my .htaccess
<files wp-config.php>
order allow,deny
deny from all
</files>
Kind regards